I'm trying to add student data into a database but keeps coming up with the error "incorrect syntax near the keyword 'Table'". I'm very new to using windows form does anybody know where I have gone wrong?
private void BTAddstudent_Click(object sender, EventArgs e)
{
try
{
string myconnection = @"Data Source = (LocalDB)\MSSQLLocalDB; AttachDbFilename = C:\Users\tayla\OneDrive\Documents\StudentPerformance\StudentPerformance\Studentdatabase.mdf; Integrated Security = True";
string Query = "Insert Into Table (ID, First name, Last name, Course 1, Course 2, Course 3, Course 4, Course 5, Course 6, Course 7, Course 8, Course 9, Course 10) values('" + this.txtbxID.Text + "','" + this.txtbxfirstname.Text + "','" + this.txtbxlastname.Text + "','" + this.txtbxcourse1.Text
+ "','" + this.txtbxcourse2.Text + "','" + this.txtbxcourse3.Text + "','" + this.txtbxcourse4.Text + "','" + this.txtbxcourse5.Text + "','" + this.txtbxcourse6.Text + "','" + this.txtbxcourse7.Text
+ "','" + this.txtbxcourse8.Text + "','" + this.txtbxcourse9.Text + "','" + this.txtbxcourse10.Text + "')";
SqlConnection myconn = new SqlConnection(myconnection);
SqlCommand mycom = new SqlCommand(Query, myconn);
SqlDataReader reader1;
myconn.Open();
reader1 = mycom.ExecuteReader();
while (reader1.Read()) ;
{
}
myconn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}