hello
another thing iam trying to add more thank one filed but i get error
foreach (ListItem lst in test_names.Items)
{
if (lst.Selected)
{
string selectedValue = lst.Value;
string patient_id = Request.QueryString["id"];
SqlConnection cnm = new SqlConnection(ConfigurationManager.ConnectionStrings["lap_connection"].ConnectionString);
SqlCommand cmd = new SqlCommand("INSERT INTO [patient_test_data] (test_id,test_date,pat_id,data_id) VALUES ('" + selectedValue + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "','" + patient_id + "');", cnm);
cmd.Connection = cnm;
cmd.CommandType = CommandType.Text;
cnm.Open();
cmd.ExecuteScalar();
cnm.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "show_error", "showSuccess('Test Has Been Added Successfully',2000);", true);
}
}
this is the error that i got
There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
i don't know how to insert with this function