C#怎么往mdb编辑写入数据

 时间:2026-04-23 07:25:45

1、创建并打开一个OleDbConnection对象

string strConn = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = sample.mdb " ;OleDbConnection myConn = new OleDbConnection ( strCon ) ;myConn.Open ( ) ;

2、创建插入的SQL语句

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 + ")" ;

3、创建一个OleDbCommand对象

OleDbCommand inst = new OleDbCommand ( strInsert , myConn ) ;

4、使用OleDbCommand对象来插入数据

inst.ExecuteNonQuery ( ) ;

5、关闭OleDbConnection

myConn.Close ( ) ;

  • 易语言如何编写倒计时关机软件?
  • 计算机工作组加入到域环境
  • 群晖如何实现ftp的匿名登录
  • Windows10禁用首次登录动画的设置方法
  • iphone6s升级ios15.6
  • 热门搜索
    鲫鱼怎么做好吃又简单 唛头怎么读 龙猫图片大全 止血方法 香囊怎么做 腌鱼的腌制方法 腰间盘突出的锻炼方法 高清风景图片大全 血小板减少怎么办 好评怎么写