access是什么意思啊了使⽤C#向ACCESS中插⼊数据
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 ( ) ;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论