<script type="text/javascript">
</script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
大家来关注下这个问题....谢谢啦~~~~~~~~~~~~
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim oledbCnstr As String
Dim oledbDate As New DataSet
oledbCnstr = provider=microsoft.jet.oledb.4.0;data source=Books.mdb
Dim oledbCn As OleDbConnection
oledbCn = New OleDbConnection(oledbCnstr)
Dim oledbsql, oledbDel, oledbIns, oledbUpdate As String
Dim oledbAdpter As OleDbDataAdapter
oledbAdpter = New OleDbDataAdapter
oledbCn.Open()
Try
oledbIns = insert into borrow (BorrowNo,CardNo,BorrowDate)values ( j001 , k002 , 1987-01-02 )
oledbAdpter.InsertCommand = New OleDbCommand(oledbIns, oledbCn)
oledbAdpter.InsertCommand.ExecuteNonQuery()
oledbAdpter.Fill(oledbDate, borrow )
DataGrid1.DataSource = oledbDate.Tables( borrow )
Catch err As Exception
MsgBox(err.ToString)
Finally
If oledbCn.State = ConnectionState.Open Then
oledbCn.Close()
oledbCn = Nothing
End If
End Try
End Sub
运行有如下提示.....
system.Data.oledb.oledbException:Insert into 语句语法错误
at system.Data.oledb.oledbcommand.ExcutecommandTextErrorhangdling(int32 hr)
at system.Data.oledb.oledbcommand.ExcutecommandTextForsingleResult(tagDBPAAMS dbParams,Object&executeResult)
at system.Data.oledb.oledbcommand.ExcutecommandText(Object&executeResult)
at system.Data.oledb.oledbcommand.Excutecommand(CommandBehavior behavior,Object&executeResult)
at system.Data.oledb.oledbcommand.ExcuteReaderInternal(CommandBehavior behavior,String method)
at system.Data.oledb.oledbcommand.ExcuteNoQuery()
at adpter1.Form1.Button2_Click(Object sender , EventArgs e) in D:/vb.net练习数据库/adpter1/Form1.vb:line 152
各位大侠给点意见,谢谢哦...
at system.Data.oledb.oledbcommandText(Object&executeResult)
__________________________________________________________________________
补充下
borrowNo文本格式
CardNo文本
BorrowDate日期
oledbIns = insert into borrow (BorrowNo,CardNo,BorrowDate)values ( j001 , k002 , 1987-01-02 ) 是在一行显示
__________________________________________________________________________
你这个 ) 是中文的...
改成)
__________________________________________________________________________
哈哈,最好的方法就是先写好SQL再粘过来
__________________________________________________________________________
^_^ ,谢谢啦,解决了,这个问题困扰我几天了,真的感谢
amandag(高歌)给你加分
__________________________________________________________________________
大家来关注下这个问题....谢谢啦~~~~~~~~~~~~
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim oledbCnstr As String
Dim oledbDate As New DataSet
oledbCnstr = provider=microsoft.jet.oledb.4.0;data source=Books.mdb
Dim oledbCn As OleDbConnection
oledbCn = New OleDbConnection(oledbCnstr)
Dim oledbsql, oledbDel, oledbIns, oledbUpdate As String
Dim oledbAdpter As OleDbDataAdapter
oledbAdpter = New OleDbDataAdapter
oledbCn.Open()
Try
oledbIns = insert into borrow (BorrowNo,CardNo,BorrowDate)values ( j001 , k002 , 1987-01-02 )
oledbAdpter.InsertCommand = New OleDbCommand(oledbIns, oledbCn)
oledbAdpter.InsertCommand.ExecuteNonQuery()
oledbAdpter.Fill(oledbDate, borrow )
DataGrid1.DataSource = oledbDate.Tables( borrow )
Catch err As Exception
MsgBox(err.ToString)
Finally
If oledbCn.State = ConnectionState.Open Then
oledbCn.Close()
oledbCn = Nothing
End If
End Try
End Sub
运行有如下提示.....
system.Data.oledb.oledbException:Insert into 语句语法错误
at system.Data.oledb.oledbcommand.ExcutecommandTextErrorhangdling(int32 hr)
at system.Data.oledb.oledbcommand.ExcutecommandTextForsingleResult(tagDBPAAMS dbParams,Object&executeResult)
at system.Data.oledb.oledbcommand.ExcutecommandText(Object&executeResult)
at system.Data.oledb.oledbcommand.Excutecommand(CommandBehavior behavior,Object&executeResult)
at system.Data.oledb.oledbcommand.ExcuteReaderInternal(CommandBehavior behavior,String method)
at system.Data.oledb.oledbcommand.ExcuteNoQuery()
at adpter1.Form1.Button2_Click(Object sender , EventArgs e) in D:/vb.net练习数据库/adpter1/Form1.vb:line 152
各位大侠给点意见,谢谢哦...
at system.Data.oledb.oledbcommandText(Object&executeResult)
__________________________________________________________________________
补充下
borrowNo文本格式
CardNo文本
BorrowDate日期
oledbIns = insert into borrow (BorrowNo,CardNo,BorrowDate)values ( j001 , k002 , 1987-01-02 ) 是在一行显示
__________________________________________________________________________
你这个 ) 是中文的...
改成)
__________________________________________________________________________
哈哈,最好的方法就是先写好SQL再粘过来
__________________________________________________________________________
^_^ ,谢谢啦,解决了,这个问题困扰我几天了,真的感谢
amandag(高歌)给你加分
__________________________________________________________________________