none
ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or Function RRS feed

  • Question

  •  

    Hi

     

    Good day

     

    I got an ODBC runtime error that takes so much pain in my brain nerves. This is what I've got actually,

     

    ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure or Function 'sp_GetDebtorAccountForICM' expects parameter '@guarantor', which was not supplied.

     

    Here is my code snippet below:

     

     

    using (OdbcConnection _conn = (OdbcConnection)this.CreateConnection())

    {

       _conn.Open();

       using (DbCommand _cmd = this.CreateCommand("sp_GetDebtorAccountForICM"))

       {

          _cmd.Connection = _conn;     

        

         OdbcCommandBuilder.DeriveParameters((OdbcCommand)cmd);

     

        _cmd.Parameters["@account"].Value = pCmdArgsInfo.Account;

        _cmd.Parameters["@client"].Value = pCmdArgsInfo.Client;

        _cmd.Parameters["@employee"].Value = pCmdArgsInfo.Employee;

        _cmd.Parameters["@guarantor"].Value = pCmdArgsInfo.Guarantor;

      

        _cmd.Prepare();

         IDataReader _rdr = _cmd.ExecuteReader(CommandBehavior.SingleResult);

       }

    }

     

    After invoking ExecuteReader() method, the OdbcCommand object has thrown an exception.

    Are there any additional ODBC configuration that needs to be configured? or is this some sort of a bug?

     

    Hoping for a positive response. I really appreciate any comments, recommendations, or suggestions.

     

    Thanks in advance.

     

    Sincerely,

    Jhessie

    Tuesday, June 3, 2008 7:35 AM

Answers

  •  

    Hi AlexBB,

     

    Thank you for your reponse.

     

    I'm sorry I'm not using the OLEDB thing, it's all about the ODBC data provider.

    Fortunately, I was able to fix it by adding this piece of text

    ({? = call ?=call sp_GetDebtorAccountForICM(?,?,?,?)}) to the property CommandText after deriving sp parameters using command builder.

     

     

    Sincerely,

    Jhessie

    Wednesday, June 4, 2008 2:34 AM

All replies

  • A good error code. You deserve itSmile. This is how the SPs should be called, not the way you do it.

     

    using ( OleDbConnection conn = new OleDbConnection ( Globals.connStr ) )

    {

    conn.Open ( );

    OleDbCommand cmdm = new OleDbCommand ( );

    cmdm.Connection = conn;

    cmdm.CommandType = CommandType.StoredProcedure;

    cmdm.CommandText = "sp_GetDebtorAccountForICM";

    cmdm.Parameters.Add ( "p_one", OleDbType.Char, 7 ).Value = pointer_one;

    cmdm.Parameters.Add ( "p_two", OleDbType.Char, 7 ).Value = pointer_two;

    cmdm.ExecuteNonQuery ( );

    }

    Tuesday, June 3, 2008 7:09 PM
  •  

    Hi AlexBB,

     

    Thank you for your reponse.

     

    I'm sorry I'm not using the OLEDB thing, it's all about the ODBC data provider.

    Fortunately, I was able to fix it by adding this piece of text

    ({? = call ?=call sp_GetDebtorAccountForICM(?,?,?,?)}) to the property CommandText after deriving sp parameters using command builder.

     

     

    Sincerely,

    Jhessie

    Wednesday, June 4, 2008 2:34 AM