insert into access database

AnnaB

New Member
i have trouble inserting data from textbox into ms access database, i get an error "Syntax error in INSERT INTO." Can someone help me out please? (i'm new to c#) here's the code:\[code\]public void button1_Click(object sender, EventArgs e)//save{ using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\productdb.mdb")){OleDbCommand CmdSql = new OleDbCommand("Insert into [product](Kod, names, price,type,volume,manufacturer,importer)enter code here{conn.Open();CmdSql.Parameters.AddWithValue("@Kod", textBox1.Text);CmdSql.Parameters.AddWithValue("@names", textBox2.Text);CmdSql.Parameters.AddWithValue("@price", textBox3.Text);CmdSql.Parameters.AddWithValue("@type", textBox4.Text);CmdSql.Parameters.AddWithValue("@volume", textBox5.Text);CmdSql.Parameters.AddWithValue("@manufacturer", textBox6.Text);CmdSql.Parameters.AddWithValue("@importer", textBox7.Text);CmdSql.ExecuteNonQuery();// i get the error here<<<conn.Close();}}\[/code\]
 
Back
Top