求助,VB查询编程.帮忙看下哪边不正确

来源:百度知道 编辑:UC知道 时间:2024/05/27 13:38:30
Private Sub Command14_Click()
Command10.Enabled = True

If Text6 = "" Then MsgBox "请输入票号", , "提示"
Dim result As Integer

Adodc1.RecordSource = "select * from 操作票 where [票号] = " + "'" + Text6 + "'"
Adodc1.Refresh

If Text30 = "" Then
result = MsgBox("查无此票,是否查找其他记录?", vbOKCancel + vbQuestion)
If result = 1 Then
Text6 = ""
Text6.SetFocus
Else
Unload Me
End
End If
End If
End Sub

Adodc1与DataGrid的连接都已经连好了.为什么运行后,在DataGrid中不能显示数据库中所要的内容呢?
Adodc1的相关设置:
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\毕业设计2\操作票管理信息系统数据库\操作票.mdb;Persist Security Info=False"
Recordsource = select * from 操作票 WHERE 票号='0'
Text30为与Text6对比的文本框,运行时为隐藏状态.

:书写格式:NO!!!
Adodc1.RecordSource = "select * from 操作票 where 票号='" & Text6.text & "'"
---------------------------
请修改后,再试!!
--------------
这是基本功呀!数字,字符,日期 各自不同,你应该会写才行!!!祝通过!!!

同意楼上的,但是你作的是毕业论文,那那么你最好用相对路径,不然拷到别的机子就用不了了.
dim TABLE as string
TABLE="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "app.path/操作票.mdb; " & "Persist Security Info=False"

ConnectionString = table