vb.net 未处理 System.Data.OleDb.OleDbException 怎么解决啊

dd0972 2010-09-17 01:19:30
Public Class Form1


Private Sub Tabpage1_Layout(ByVal sender As Object, ByVal e As System.Windows.Forms.LayoutEventArgs) Handles Tabpage1.Layout
Me.图书销售管理DataSet.Clear()
Me.OleDbDataAdapter1.Fill(图书销售管理DataSet, "图书基本资料")
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.图书基本资料BindingSource.MoveFirst()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.图书基本资料BindingSource.MovePrevious()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.图书基本资料BindingSource.MoveNext()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.图书基本资料BindingSource.MoveLast()
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
' ComboBox1.Items.Add("按书名查找")
If ComboBox1.SelectedItem = "按书名查找" Then
TextBox1.Enabled = True
End If
If ComboBox1.SelectedItem = "按作者查找" Then
TextBox1.Enabled = True
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str_select As String = "select * from 图书基本资料"
If ComboBox1.SelectedItem = "按书名查找" Then
str_select = str_select & "where 书名='" & Trim(TextBox1.Text)
End If
If ComboBox1.SelectedItem = "按作者查找" Then
str_select = str_select & "where 作者='" & Trim(TextBox1.Text)
End If
Me.OleDbConnection1.Open()
Me.OleDbSelectCommand1.CommandText = str_select
Me.OleDbSelectCommand1.ExecuteNonQuery()
Me.图书销售管理DataSet.Clear()
Me.OleDbDataAdapter1.Fill(图书销售管理DataSet, "图书基本资料")
Me.OleDbConnection1.Close()
End Sub
End Class






在 Me.OleDbSelectCommand1.ExecuteNonQuery()显示未处理 System.Data.OleDb.OleDbException

怎么弄呐
...全文
81 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dd0972 2010-09-17
  • 打赏
  • 举报
回复
谢谢炎龙无悔 jathon啦 ~~ 解决了
哈哈
好吃的松子 2010-09-17
  • 打赏
  • 举报
回复
Dim str_select As String = "select * from 图书基本资料"
If ComboBox1.SelectedItem = "按书名查找" Then
str_select = str_select & "where 书名='" & Trim(TextBox1.Text)
End If

注意where前面需要空格,不然就成select * from 图书基本资料where 书名=....了
yanlongwuhui 2010-09-17
  • 打赏
  • 举报
回复
SQL语句有问题吧。试试如下:
Dim str_select As String = "select * from 图书基本资料"
If ComboBox1.SelectedItem = "按书名查找" Then
str_select = str_select & " where 书名='" & Trim(TextBox1.Text) &"'"
End If
If ComboBox1.SelectedItem = "按作者查找" Then
str_select = str_select & " where 作者='" & Trim(TextBox1.Text) & "'"
End If
messi_yang 2010-09-17
  • 打赏
  • 举报
回复
你的錯誤的代碼在哪裡啊?
dd0972 2010-09-17
  • 打赏
  • 举报
回复
求助啊~~

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧