N
Neraks
Guest
Must declare the scalar variable @code
I tried with no dynamic query n its works , but when i tried to pass parameters send me that error , please help me
Regards
public void Insert()
{
ReglaController re = new ReglaController();
re.Regla_2();
string constr = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
con.Open();
string query = "INSERT INTO test (r1) VALUES (@code)";
using (SqlCommand cmd = new SqlCommand(query, con))
{
cmd.ExecuteNonQuery();
cmd.Parameters.Add("@code", SqlDbType.NVarChar).Value = re.Regla_2();
}
}
}
Continue reading...
I tried with no dynamic query n its works , but when i tried to pass parameters send me that error , please help me
Regards
public void Insert()
{
ReglaController re = new ReglaController();
re.Regla_2();
string constr = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
con.Open();
string query = "INSERT INTO test (r1) VALUES (@code)";
using (SqlCommand cmd = new SqlCommand(query, con))
{
cmd.ExecuteNonQuery();
cmd.Parameters.Add("@code", SqlDbType.NVarChar).Value = re.Regla_2();
}
}
}
Continue reading...