SqlCommand cmd = new SqlCommand(mySQL, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
This is my codes, I want to update this into my database however its not working and I can't find any build errors. Would really appreciate the help!!! I am using SQL Sever 2008 to store my data.
cherylteo93
0 Points
2 Posts
Facing problems updating database
Feb 16, 2013 04:48 PM|LINK
Hello. I have been having problems for some time,
protected void Button6_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=localhost;" +
"Initial Catalog=ASPProject; Integrated Security=SSPI");
conn.Open();
string mySQL;
mySQL = " INSERT into JobApply (Apply_Name, Apply_User,Apply_Job) VALUES ('"+ txtName.Text.Trim() + "','" + txtUser.Text.Trim() + "','" + txtApply.Text.Trim() + "')";
SqlCommand cmd = new SqlCommand(mySQL, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
This is my codes, I want to update this into my database however its not working and I can't find any build errors. Would really appreciate the help!!! I am using SQL Sever 2008 to store my data.
Vipindas
Contributor
5514 Points
810 Posts
Re: Facing problems updating database
Feb 16, 2013 05:18 PM|LINK
Chk this
protected void Button6_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=localhost;" + "Initial Catalog=ASPProject; Integrated Security=SSPI"); conn.Open(); string mySQL; mySQL = " INSERT into JobApply (Apply_Name, Apply_User,Apply_Job) VALUES (@Name,@User,@Job)"; SqlCommand cmd = new SqlCommand(mySQL, conn); command.Parameters.AddWithValue("Name", txtName.Text.Trim()); command.Parameters.AddWithValue("User", txtUser.Text.Trim()); command.Parameters.AddWithValue("Job", txtJob.Text.Trim()); cmd.ExecuteNonQuery(); conn.Close(); }