Im trying to add items to my database using C#.
I have a database with 2 tables:
“Project Parts”
“Project Table” , in this table there is a column named “Project Name”
but im getting this error:
There was an error parsing the query. [ Token line number = 1,Token
line offset = 21,Token in error = Table ]
Here is the code im using.
private void button1_Click(object sender, EventArgs e)
{
sqlCEC.Open();
//Project_List.Items.Add(new_project_name.Text.ToString());
SqlCeCommand sqlCEcommand = new SqlCeCommand("INSERT INTO Project Table(Project Name) VALUES(@Project Name)", sqlCEC);
sqlCEcommand.Parameters.AddWithValue("@Project Name", new_project_name.Text);
sqlCEcommand.ExecuteNonQuery();
sqlCEC.Close();
}
How about?
Because your database objects contains spaces, you need to enclose them with
[]My humble advice is, never use spaces or other special characters in your tables or your column names.