我正在使用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();
}
连接erorr
在System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle,RetCode retcode)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior,String method,Boolean needReader,Object [] methodArguments,SQL_API odbcApiMethod)
在System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior,String method,Boolean needReader)
在System.Data.Odbc.OdbcCommand.ExecuteNonQuery()