注册 登录
编程论坛 VB.NET论坛

求助:设计遇到个问题,请高手们帮下忙!

freedomGD 发布于 2008-06-06 14:40, 983 次点击
我做了个模糊查询,但运行时总出现"未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.data.dll 中。"光标总停在 objda.Fill(objds, "xs"),请高手们告诉我出了什么问题,谢谢!


代码如下:
 Public Sub bindgridview(ByVal strXH As String)
        Dim objconn As New OleDb.OleDbConnection
        Dim objda As New OleDb.OleDbDataAdapter
        Dim objcomm As New OleDb.OleDbCommand
        Dim objds As New DataSet
        Dim wherestr As String

objconn.ConnectionString = "Provider=Microsoft.jet.OLEDB.4.0;data source='C:\Documents and Settings\Administrator\桌面\学生成绩管理系统\XSCJ.mdb'"

objcomm.Connection = objconn
        objda.SelectCommand = objcomm
        Dim builder As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(objda)

        objconn.Open()
        objda.Fill(objds, "xs")                   ( 绿光标停在此处)

        objconn.Close()
        DataGrid1.DataSource = objds.Tables("xs")
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim wherestr As String
        Dim objds As New DataSet
        wherestr = ""
        If Trim(txtxh.Text) <> "" Then
            wherestr = "Select * form xs where xh like % & Trim(txtxh.Text) & %"
            MsgBox(wherestr)
        End If

        objds.Tables.Clear()           
        bindgridview(WhereStr)

End Sub
0 回复
1