protected void Button1_Click(object sender, EventArgs e)
{
String insertSQL;
insertSQL = "INSERT INTO SERVICES (";
insertSQL += "Service_Code, Service_Name)";
insertSQL += "VALUES (";
insertSQL += "@Service_Code, @Service_Name)";
String connectionstring = WebConfigurationManager.ConnectionStrings["HelpDesk_System"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand(insertSQL, conn);
cmd.Parameters.AddWithValue("@Service_Code", TextBox1.Text);
cmd.Parameters.AddWithValue("@Service_Name", TextBox2.Text);
int added = 0;
try
{
conn.Open();
added = cmd.ExecuteNonQuery();
UpdatePanel1.Update();
conn.Close();
}
catch (Exception err)
{
Label1.Text = "Error inserting";
Label2.Text += err.Message;
}
}
}
|