I am fairly new to C# i have a database which i need fill with windows forms, the button that inserts data into the table has the following code:
private void btnAddEmployee_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("server=.\\server1; database = PMS; Integrated security=true;");
SqlDataAdapter da = new SqlDataAdapter("INSERT INTO tblEmployees cid, empID, empFirstName, empMidName, "
+"empLastName, empAge, empTitle, empAddress, empRank, empSalary, empEmail, empPhone, "
+"empMobile, Notes, userName, usrPassword, usrAccessLevel, empActive, empMarked, empType "
+"VALUES ('" + this.txtID + "', '" + this.txtEmpID + "', '" + this.txtFirstName + "','" + this.txtMidName + "'," +
" '" + this.txtLastName + "', '" + this.txtEmpAge + "', '" + this.txtJobTitle + "', '" + this.txtAddress + "', " +
" '" + this.cmbRank + "', '" + this.txtSalary + "', '" + this.txtEmail + "', '" + this.txtPhone + "', " +
" '" + this.txtMobile + "', '" + this.txtNote + "', '" + this.txtUserName + "', '" + this.txtPassword + "', " +
" '" + this.cmbAcsLevel + "', '" + this.txtActive + "', '" + this.txtMarked + "', '" + this.txtType + "')", cn);
if (cn.State != ConnectionState.Open)
{
cn.Open();
}
object o = da.SelectCommand.ExecuteNonQuery();
cn.Close();
}
however after clicking the button i get the following error:
System.Data.SqlClient.SqlException: 'Incorrect syntax near 'cid'.'