但是前后台的参数都已经对应上了,请高手帮忙看看:
前台调用的代码: RunProcedure函数:存储过程是定义了三个输入参数,一个游标输出参数:
2
3 PROCEDURE P_REFER(
4 P_MATERIAL_CODE IN K_STORAGE_MB.MATERIAL_CODE%TYPE,
5 P_NAME_SX IN K_STORAGE_MB.NAME_SX%TYPE,
6 P_SPECANDTYPE IN K_STORAGE_MB.SPECANDTYPE%TYPE,
7 P_CUR OUT C_CUR
8 )IS
9 BEGIN
10 OPEN P_CUR FOR
11 SELECT * FROM K_STORAGE_MB S
12 WHERE NVL(S.MATERIAL_CODE,'NULL') LIKE P_MATERIAL_CODE||'%'
13 AND NVL(S.NAME_SX,'NULL') LIKE UPPER(P_NAME_SX)||'%'
14 AND NVL(S.SPECANDTYPE,'NULL') LIKE P_SPECANDTYPE||'%'
15 AND S.STOCK_QUANTITY != 0
16 ORDER BY S.MATERIAL_CODE;
17 END P_REFER;
18 end PKG_DA0100C;
2 {
3
4 OracleParameter[] parameters = {
5 new OracleParameter("MATERIAL_CODE", OracleType.VarChar,12),
6 new OracleParameter("NAME_SX", OracleType.VarChar,150),
7 new OracleParameter("SPECANDTYPE", OracleType.VarChar,1000),
8 new OracleParameter("cursor",OracleType.Cursor),
9 };
10
11
12 parameters[0].Value = Convert.ToString(txt_mat_no.Text);
13 parameters[1].Value = Convert.ToString(txt_pysx.Text);
14 parameters[2].Value = Convert.ToString(txt_specandtype.Text);
15
16 parameters[3].Direction = ParameterDirection.Output;
17
18 DataSet ds = DbHelperOra.RunProcedure("PKG_DA0100C.P_REFER", parameters, "STORGE_INFO");
19 }
1 public static DataSet RunProcedure(string storedProcName, IDataParameter[] parameters, string tableName)
2 {
3 using (OracleConnection connection = new OracleConnection(connectionString))
4 {
5 DataSet dataSet = new DataSet();
6 connection.Open();
7 OracleDataAdapter sqlDA = new OracleDataAdapter();
8 //sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, parameters );
9
10 OracleCommand command = new OracleCommand(storedProcName, connection);
11 command.CommandType = CommandType.StoredProcedure;
12
13 foreach (OracleParameter parameter in parameters)
14 {
15 command.Parameters.Add(parameter);
16 }
17 sqlDA.SelectCommand = command;
18 sqlDA.Fill( dataSet, tableName );
19 connection.Close();
20 return dataSet;
21 }
22 }
执行到RunProcedure 18行sqlDA.Fill( dataSet, tableName );的时候出错,报错为参数类型或个数不正确,不知道哪里出错了,请高手指点!