locked
ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4 RRS feed

  • Question

  • User-757609608 posted

                            OdbcConnection con = new OdbcConnection(getDataConnection());
                            OdbcCommand cmd = new OdbcCommand();

                            cmd.CommandText = "Update LssJobList set Status=@Status, EndDate=@EndDate where JobID=@JobID and  COID = @NO";
                            cmd.Connection = con;


                            OdbcParameter pstrJobID = new OdbcParameter("@JobID", OdbcType.VarChar, 30);
                            pstrJobID.Direction = ParameterDirection.Input;
                            pstrJobID.Value = objReceive._strJobID;
                            cmd.Parameters.Add(pstrJobID);

                            OdbcParameter pstrCOID = new OdbcParameter("@NO", OdbcType.VarChar, 30);
                            pstrCOID.Direction = ParameterDirection.Input;
                            pstrCOID.Value = objReceive._strCOID;
                            cmd.Parameters.Add(pstrCOID);

                            OdbcParameter pintStatus = new OdbcParameter("@Status", OdbcType.Int);
                            pintStatus.Direction = ParameterDirection.Input;
                            pintStatus.Value = objReceive._intStatus;
                            cmd.Parameters.Add(pintStatus);

                            OdbcParameter pstrEndDate = new OdbcParameter("@EndDate", OdbcType.VarChar, 25);
                            pstrEndDate.Direction = ParameterDirection.Input;                       
                            pstrEndDate.IsNullable = true;
                            pstrEndDate.Value = objReceive._strEndDate;
                            cmd.Parameters.Add(pstrEndDate);

                            OdbcDataAdapter da = new OdbcDataAdapter(cmd);
                            DataSet ds = new DataSet();
                            con.Open();
                            cmd.ExecuteNonQuery();

       at Execution I am getyting this error...........

       ERROR [07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4

     

     

     

    Thursday, November 27, 2008 4:40 AM

Answers

  • User-1199946673 posted

    I would suggest that You use OleDB instead of ODBC. OleDb parameter are recognized by their position, not by their name, so they must be added in the same order they appear in the database, although I'm not sure if this is the case also when using ODBC with an access database

    http://www.mikesdotnetting.com/Article.aspx?ArticleID=26

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 27, 2008 9:16 AM

All replies

  • User-1199946673 posted

    I would suggest that You use OleDB instead of ODBC. OleDb parameter are recognized by their position, not by their name, so they must be added in the same order they appear in the database, although I'm not sure if this is the case also when using ODBC with an access database

    http://www.mikesdotnetting.com/Article.aspx?ArticleID=26

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 27, 2008 9:16 AM
  • User-757609608 posted
    http://www.mikesdotnetting.com/Article.aspx?ArticleID=26
    Thursday, November 27, 2008 11:07 PM
  • User-821857111 posted

     

    Parameter Queries in ASP.NET with MS Access

     .......

    I'd be grateful if you didn't just copy and paste the content of my web site here.  You are in breach of my copyright.

    Thanks

     

    Friday, November 28, 2008 7:14 AM