0

Error while setting parameter in the sql query

string cs = ConfigurationManager.ConnectionStrings["conString"].ConnectionString.ToString();
OdbcConnection con = new OdbcConnection(cs);


OdbcCommand cmd = new OdbcCommand("select CustomerID, LastName, FirstName from Customers.Customer.Customer_Details where CustomerID = @ID", con);
con.Open();
cmd.Parameters.AddWithValue("@ID", Convert.ToInt32(txtID.Text));
OdbcDataReader reader = cmd.ExecuteReader();
शेखर
  • 17,412
  • 13
  • 61
  • 117
Bhuwan Pandey
  • 514
  • 1
  • 6
  • 19
  • Earlier answers just told to add value for the parameter, but I don't think that is something in my question. – Bhuwan Pandey Sep 22 '15 at 05:49
  • it's clear in the answer you need to use `?` and then add parameters. In your case it should be `OdbcCommand cmd = new OdbcCommand("select CustomerID, LastName, FirstName from Customers.Customer.Customer_Details where CustomerID = ?", con);` rest will be as it is. – शेखर Sep 22 '15 at 05:51
  • Thanks a lot shekhar it worked. – Bhuwan Pandey Sep 22 '15 at 05:54

0 Answers0