'How to declare scalar variable?
I get this error:
System.Data.SqlClient.SqlException: 'Must declare the scalar variable "@refSlips".'
Code:
SqlConnection con = new SqlConnection(connectionString);
SqlCommand aaa = new SqlCommand("INSERT INTO ConsultationTB VALUES('" + consultationTb.Text + "','" + dateTb.Text + "','" + bodytempTb.Text + "','" + paccodeTb.Text + "', @refSlips ", con);
string RadButt = string.Empty;
if (ForAdmission.Checked)
{
RadButt = "For Admission";
}
else if (ForLabTest.Checked)
{
RadButt = "For Laboratory Test";
}
else if (BothRb.Checked)
{
RadButt = "Both";
}
else if (NotAppRb.Checked)
{
RadButt = "Not Applicable";
}
con.Open();
aaa.ExecuteNonQuery();
con.Close();
getCONNO();
ForAdmission.Checked = false;
ForLabTest.Checked = false;
BothRb.Checked = false;
NotAppRb.Checked = false;
Solution 1:[1]
[ + "', @refSlips)" , con);] the problem was the parenthesis after refslips.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | JD Hahaha |