I'm a student of Computer science and I'm working on some C# applications at home for practice. I have created a local database (.mdf) and I'm trying to add some data through text boxes.
// I have this code for sending the data to the database which I have already connected with.
private void BtnSubmitD_Click(object sender, EventArgs e)
{
cmd.CommandText = "inster into st(Student's ID) values ('"+txtID.Text+"' )";
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Data has beed record.");
}
This error message keeps coming up:
system.data.sqlclient.sqlexception 'incorrect syntax near the keyword 'into'.' Unclosed quotation mark after the character string ' )'.'