Error while calling stored procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PrakashN
    New Member
    • Sep 2007
    • 43

    Error while calling stored procedure

    Hi,
    While executing the com.com.Execute NonQuery() error it shows the error as

    ERROR [42000] [Microsoft][SQL Native Client][SQL Server]Procedure or Function 'AddCustomer' expects parameter '@ID', which was not supplied.

    But i am passing the parameter..
    Please help me.
    Here is the Code

    OdbcCommand com = new OdbcCommand("Ad dCustomer",conn );
    com.CommandType = CommandType.Sto redProcedure;
    com.Parameters. Add("@ID", OdbcType.NVarCh ar,12,"20" );
    com.Parameters. Add("@FName", OdbcType.NVarCh ar, 50, (txtFirstName.T ext));
    com.Parameters. Add("@LName", OdbcType.NVarCh ar, 30, txtLastName.Tex t);
    com.Parameters. Add("@Add1", OdbcType.NVarCh ar, 50, txtAdd1.Text);
    com.Parameters. Add("@Add2", OdbcType.NVarCh ar, 50, txtAdd2.Text);
    com.Parameters. Add("@City", OdbcType.NVarCh ar, 50, drpState.Text);
    com.Parameters. Add("@State", OdbcType.NVarCh ar, 20, drpState.Text);
    com.Parameters. Add("@Pincode", OdbcType.NVarCh ar, 6, txtPincode.Text );
    com.Parameters. Add("@Phone", OdbcType.NVarCh ar, 25, txtPhone.Text);
    com.Parameters. Add("@Country", OdbcType.NVarCh ar, 20, txtCountry.Text );
    com.Parameters. Add("@Email", OdbcType.NVarCh ar, 50, txtEmail.Text);
    com.ExecuteNonQ uery();
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Try to add "New" Parameter:

    com.Parameters. Add(New OdbcParameter(" @ID", OdbcType.NVarCh ar,12,"20" ))

    REgards
    Veena

    Comment

    • PrakashN
      New Member
      • Sep 2007
      • 43

      #3
      Originally posted by QVeen72
      Hi,

      Try to add "New" Parameter:

      com.Parameters. Add(New OdbcParameter(" @ID", OdbcType.NVarCh ar,12,"20" ))

      REgards
      Veena
      Hi,

      But still it showing the same error..
      Please help me

      Thank you
      Parakash N

      Comment

      • QVeen72
        Recognized Expert Top Contributor
        • Oct 2006
        • 1445

        #4
        Hi,

        I guess, you are using the SP to Add records in Table..
        Is ID field, defined as AutoGenerated in database table..?
        If yes, then you will get error..
        anyways, you can check This Link


        REgards
        Veena

        Comment

        Working...