using parameters inserting data into access database

前端 未结 4 1212
无人及你
无人及你 2020-11-22 11:04

I have the following method to inserting data into a an access databasewhich works fine but I do get a problem if I try to insert text that contains single quotes I have lea

4条回答
  •  太阳男子
    2020-11-22 11:15

                    OleDbCommand cmd = new OleDbCommand("insert into table_name (ID,Type,SrNo) Values ('" + textboxId.Text + "','" + textboxType.Text + "' ,'" + textboxSr.Text + "');", oc);
                    cmd.CommandType = CommandType.Text;
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Data has been saved successfully");
                   cmd.Dispose();
    

提交回复
热议问题