When I try to run this code I get the following error: An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
This is my code:
protected void ButtonAdd_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(strcon); string Id = DropDownListB.DataValueField; SqlCommand cmd = new SqlCommand("SELECT Price FROM BooksInfo WHERE ISBN No=@Id", con); cmd.Parameters.AddWithValue("@Id", Id); con.Open(); string test = (String)cmd.ExecuteScalar(); LabelQuantity.Text = test; con.Close(); }