Ejemplo n.º 1
0
        private static DataSet GetProcData(MySqlConnection connection, string spName)
        {
            int    index = spName.IndexOf(".");
            string str   = spName.Substring(0, index);
            string str2  = spName.Substring(index + 1, (spName.Length - index) - 1);

            string[] restrictionValues = new string[4];
            restrictionValues[1] = (str.Length > 0) ? str : connection.CurrentDatabase();
            restrictionValues[2] = str2;
            DataTable schema = connection.GetSchema("procedures", restrictionValues);

            if (schema.Rows.Count > 1)
            {
                throw new MySqlException(Resources.ProcAndFuncSameName);
            }
            if (schema.Rows.Count == 0)
            {
                throw new MySqlException(string.Format(Resources.InvalidProcName, str2, str));
            }
            DataTable procedureParameters = new ISSchemaProvider(connection).GetProcedureParameters(restrictionValues, schema);
            DataSet   set = new DataSet();

            set.Tables.Add(schema);
            set.Tables.Add(procedureParameters);
            return(set);
        }
Ejemplo n.º 2
0
        private DataSet GetParameters(string procName)
        {
            if (base.Connection.Settings.UseProcedureBodies)
            {
                return(base.Connection.ProcedureCache.GetProcedure(base.Connection, procName));
            }
            DataSet set = new DataSet();

            string[] restrictionValues = new string[4];
            int      index             = procName.IndexOf('.');

            restrictionValues[1] = procName.Substring(0, index++);
            restrictionValues[2] = procName.Substring(index, procName.Length - index);
            set.Tables.Add(base.Connection.GetSchema("procedures", restrictionValues));
            DataTable routines            = new DataTable();
            DataTable procedureParameters = new ISSchemaProvider(base.Connection).GetProcedureParameters(null, routines);

            procedureParameters.TableName = "procedure parameters";
            set.Tables.Add(procedureParameters);
            int num2 = 1;

            foreach (MySqlParameter parameter in base.command.Parameters)
            {
                if (!parameter.TypeHasBeenSet)
                {
                    throw new InvalidOperationException(Resources.NoBodiesAndTypeNotSet);
                }
                DataRow row = procedureParameters.NewRow();
                row["PARAMETER_NAME"] = parameter.ParameterName;
                row["PARAMETER_MODE"] = "IN";
                if (parameter.Direction == ParameterDirection.InputOutput)
                {
                    row["PARAMETER_MODE"] = "INOUT";
                }
                else if (parameter.Direction == ParameterDirection.Output)
                {
                    row["PARAMETER_MODE"] = "OUT";
                }
                else if (parameter.Direction == ParameterDirection.ReturnValue)
                {
                    row["PARAMETER_MODE"]   = "OUT";
                    row["ORDINAL_POSITION"] = 0;
                }
                else
                {
                    row["ORDINAL_POSITION"] = num2++;
                }
                procedureParameters.Rows.Add(row);
            }
            return(set);
        }
Ejemplo n.º 3
0
		private static DataSet GetProcData(MySqlConnection connection, string spName) {
			int index = spName.IndexOf(".");
			string str = spName.Substring(0, index);
			string str2 = spName.Substring(index + 1, (spName.Length - index) - 1);
			string[] restrictionValues = new string[4];
			restrictionValues[1] = (str.Length > 0) ? str : connection.CurrentDatabase();
			restrictionValues[2] = str2;
			DataTable schema = connection.GetSchema("procedures", restrictionValues);
			if (schema.Rows.Count > 1) {
				throw new MySqlException(Resources.ProcAndFuncSameName);
			}
			if (schema.Rows.Count == 0) {
				throw new MySqlException(string.Format(Resources.InvalidProcName, str2, str));
			}
			DataTable procedureParameters = new ISSchemaProvider(connection).GetProcedureParameters(restrictionValues, schema);
			DataSet set = new DataSet();
			set.Tables.Add(schema);
			set.Tables.Add(procedureParameters);
			return set;
		}
Ejemplo n.º 4
0
		private DataSet GetParameters(string procName) {
			if (base.Connection.Settings.UseProcedureBodies) {
				return base.Connection.ProcedureCache.GetProcedure(base.Connection, procName);
			}
			DataSet set = new DataSet();
			string[] restrictionValues = new string[4];
			int index = procName.IndexOf('.');
			restrictionValues[1] = procName.Substring(0, index++);
			restrictionValues[2] = procName.Substring(index, procName.Length - index);
			set.Tables.Add(base.Connection.GetSchema("procedures", restrictionValues));
			DataTable routines = new DataTable();
			DataTable procedureParameters = new ISSchemaProvider(base.Connection).GetProcedureParameters(null, routines);
			procedureParameters.TableName = "procedure parameters";
			set.Tables.Add(procedureParameters);
			int num2 = 1;
			foreach (MySqlParameter parameter in base.command.Parameters) {
				if (!parameter.TypeHasBeenSet) {
					throw new InvalidOperationException(Resources.NoBodiesAndTypeNotSet);
				}
				DataRow row = procedureParameters.NewRow();
				row["PARAMETER_NAME"] = parameter.ParameterName;
				row["PARAMETER_MODE"] = "IN";
				if (parameter.Direction == ParameterDirection.InputOutput) {
					row["PARAMETER_MODE"] = "INOUT";
				} else if (parameter.Direction == ParameterDirection.Output) {
					row["PARAMETER_MODE"] = "OUT";
				} else if (parameter.Direction == ParameterDirection.ReturnValue) {
					row["PARAMETER_MODE"] = "OUT";
					row["ORDINAL_POSITION"] = 0;
				} else {
					row["ORDINAL_POSITION"] = num2++;
				}
				procedureParameters.Rows.Add(row);
			}
			return set;
		}