当我运行此代码时,我正在使用 c# odbc for oracle g10,它给了我以下错误,请帮助谢谢。
错误在行记录 = cmd.ExecuteNonQuery();
OdbcConnection connection = new OdbcConnection();
try
{
connection = new OdbcConnection(String.Format("DSN={0};Uid={1};Pwd={2};", txtDsn.Text, txtUsername.Text, txtPassword.Text));
OdbcCommand cmd = new OdbcCommand();
cmd.CommandText = string.Format("call {0}.GETACCOUNT(?,?)", txtDB.Text);
cmd.Connection = connection;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Clear();
//stored procedure sql input paramaters.
OdbcParameter accountNumber = cmd.Parameters.Add("@ACCOUNTNUMBER", OdbcType.VarChar);
accountNumber.Direction = ParameterDirection.Input;
cmd.Parameters[0].Value = txtAccountNumber.Text;
//output parameters
OdbcParameter accountStatus = cmd.Parameters.Add("@ACCOUNT_STATUS", OdbcType.VarChar, 50);
accountStatus.Direction = ParameterDirection.Output;
try
{
if (!connection.State.Equals(ConnectionState.Open))
{
connection.Open();
}
}
int record = 0;
record = cmd.ExecuteNonQuery();
try
{
txtResult.AppendText(string.Format("Account Status: {0} {1}", accountStatus.Value, Environment.NewLine));
}
Catch(Exception ex
{
txtResult.AppendText(string.Format("Executing result Error{0} {1}{2}", ex.Message, ex.StackTrace, ex.Data));
}
}
catch (Exception ex)
{
txtResult.AppendText(string.Format("connection erorr {0} {1}", ex.Message, ex.StackTrace));
}
}
catch (Exception ex)
{
txtResult.AppendText((String.Format("retrive data fail: {0} {1}", ex.Message, ex.StackTrace)));
}
finally
{
connection.Close();
}
System.Data.Odbc.OdbcConnection.HandleError( OdbcHandle
hrHandle, RetCode retcode) 在 System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 行为, String 方法, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod) 的连接错误。 System.Data.Odbc.OdbcCommand.ExecuteNonQuery() 处的 Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 行为,字符串方法,布尔需要读取器)