protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=KING;Initial Catalog=semasinter;Integrated Security=True");
SqlCommand command = new SqlCommand("insert into StudentApplication", conn);
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "spinsertstudentapplication";
command.Parameters.AddWithValue("@Student_id", TextBox1.Text);
//command.Parameters.AddWithValue ("@Select_Course", ddlCourse.SelectedValue);
command.Parameters.AddWithValue("@Select_Country", TextBox4.Text);
command.Parameters.AddWithValue("@Select_State", TextBox2.Text);
command.Parameters.AddWithValue("@Select_Franchise", TextBox3.Text);
command.Parameters.AddWithValue("@Select_Sensei", ddlSensei.SelectedValue);
command.Parameters.AddWithValue("@Group", TextBox6.Text);
command.Parameters.AddWithValue("@Enter_Student_Name", TextBox7.Text);
command.Parameters.AddWithValue("@Enter_Student_Address", TextBox8.Text);
command.Parameters.AddWithValue("@Students_Father_Name", TextBox9.Text);
command.Parameters.AddWithValue("@Student_DOB", TextBox10.Text);
if (RadioButton2.Checked == true)
{
command.Parameters.Add("@Gender", SqlDbType.Bit).Value = true;
}
else
{
command.Parameters.Add("@Gender", SqlDbType.Bit).Value = false;
}
command.Parameters.Add("@Enter_Kyu", SqlDbType.NVarChar).Value = TextBox11.Text;
conn.Open();
int rows = command.ExecuteNonQuery(); //// in these line i got a error message
conn.Close();
}
u能帮助我的朋友PLZ如何显示一个错误消息,如果在C#中的数据已经被插入到数据库中
帮助?什么?你没有问一个问题。 – Oded 2010-07-03 08:11:21
你会得到什么错误消息? – KroaX 2010-07-03 08:14:37
告诉我们更多关于您插入的表格的信息。它有任何的UNIQUE索引吗?你现在是否有例外,如果是的话,他们说什么? – 2010-07-03 08:18:49