string dbconnection = "Provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=Book.mdb"; OleDbConnection con = new OleDbConnection(dbconnection); OleDbCommand cmd = new OleDbCommand("INSERT INTO Books(BookKey,Title,Pages,AuthorKey,PublisherID) VALUES (?,?,?,?,?)", con);
cmd.Parameters.Add("@BookKey", OleDbType.VarChar, 50, "BookKey").Value = textBox1.Text; cmd.Parameters.Add("@Title", OleDbType.VarChar).Value = textBox2.Text; cmd.Parameters.Add("@Pages", OleDbType.VarChar).Value = textBox3.Text; cmd.Parameters.Add("@AuthorKey", OleDbType.VarChar).Value = textBox4.Text; cmd.Parameters.Add("@PubliherID", OleDbType.VarChar).Value = textBox5.Text;
con.Open(); cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close();
refreshlist(); |