如何在VB2005文本框中添加文本,点添加按钮会显示在下面DataGridView框里。我用的是SQL数据库,添加Book表 15
我自己写的代码可是运行部了,哪位高手帮帮忙吧。或者帮我写下。添加控件是Button2,我用的是编程方式,运行Values会提示应为结束语句,是怎么回事。PrivateSu...
我自己写的代码可是运行部了,哪位高手帮帮忙吧。
或者帮我写下。添加控件是Button2,我用的是编程方式,运行Values会提示应为结束语句,是怎么回事。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim da As New OleDb.OleDbDataAdapter
Dim comm As New OleDb.OleDbCommand
Dim sqlstr As String = ""
Dim bookname, author, bookid, ISBN As String
bookname = TextBox6.Text
author = TextBox5.Text
bookid = TextBox3.Text
ISBN = TextBox4.Text
Dim str As String
str = "insert into Book(bookname,author,bookid,ISBN)" 'values ('"&bookname&"','"&author&"','"& bookid&"','"&ISBN&"') "
comm.Connection = Me.OleDbConnection1
comm.CommandType = CommandType.Text
comm.CommandText = "insert into book values where " & sqlstr
da.InsertCommand = comm
Me.DataSet1.Clear()
Me.OleDbDataAdapter1.Fill(Me.DataSet1, "b3")
Me.DataGridView1.DataSource = Me.DataSet1.Tables("b3")
End Sub
End Class
代码可能有错,哪位好心人帮我写个新的,实在是写不出来,在线等。 展开
或者帮我写下。添加控件是Button2,我用的是编程方式,运行Values会提示应为结束语句,是怎么回事。
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim da As New OleDb.OleDbDataAdapter
Dim comm As New OleDb.OleDbCommand
Dim sqlstr As String = ""
Dim bookname, author, bookid, ISBN As String
bookname = TextBox6.Text
author = TextBox5.Text
bookid = TextBox3.Text
ISBN = TextBox4.Text
Dim str As String
str = "insert into Book(bookname,author,bookid,ISBN)" 'values ('"&bookname&"','"&author&"','"& bookid&"','"&ISBN&"') "
comm.Connection = Me.OleDbConnection1
comm.CommandType = CommandType.Text
comm.CommandText = "insert into book values where " & sqlstr
da.InsertCommand = comm
Me.DataSet1.Clear()
Me.OleDbDataAdapter1.Fill(Me.DataSet1, "b3")
Me.DataGridView1.DataSource = Me.DataSet1.Tables("b3")
End Sub
End Class
代码可能有错,哪位好心人帮我写个新的,实在是写不出来,在线等。 展开
展开全部
没细看,改一下试试:
str = "insert into Book(bookname,author,bookid,ISBN) values ('"&bookname&"','"&author&"','"& bookid&"','"&ISBN&"') "
str = "insert into Book(bookname,author,bookid,ISBN) values ('"&bookname&"','"&author&"','"& bookid&"','"&ISBN&"') "
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询