用Visual C#向access添加数据.docxVIP

  • 5
  • 0
  • 约小于1千字
  • 约 1页
  • 2022-06-26 发布于上海
  • 举报
用 Visual C#向 access 添加数据 创建并打开一个 OleDbConnection 对象。 创建一个插入一条记录的 SQL 语句。 创建一个 OleDbCommand 对象。 通过此 OleDbCommand 对象完成对插入一条记录到数据库的操作。以下是在程序中实现的具体语句: string strConn = Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = sample.mdb ; OleDbConnectionmyConn = new OleDbConnection ( strConn ) ; myConn.Open ( ) ; string strInsert = INSERT INTO books ( bookid , booktitle , bookauthor , bookprice , bookstock ) VALUES ( ; strInsert += t_bookid.Text + , ; strInsert += t_booktitle.Text + , ; strInsert += t_bookauthor.Text + , ; strInsert += t_bookprice.Text + , ; strInsert += t_bookstock.Text + ) ; OleDbCommandinst = new OleDbCommand ( strInsert , myConn ) ; inst.ExecuteNonQuery ( ) ; myConn.Close ( ) ;

文档评论(0)

1亿VIP精品文档

相关文档