feifeify 2016-11-16 06:40
浏览 664

Vb用控件adodc连接数据库,运行时显示 对象车位信息无效,可在sql里可以查到表,怎么回事?

Option Explicit
Public flag As Integer
Public userID As String
Public userkind As Integer
Public ingid As Recordset
Public movieid As String
Global cn As ADODB.Connection
Global rs As ADODB.Recordset
Global sql As String
Global usernum As Integer

Option Explicit
Private query As String

Private Sub Command1_Click()
Call setSQL
Adodc1.RecordSource = query
If Not Option1.Value Then
MsgBox "没选择查询方式!"
Adodc1.Refresh
Set rsgrid.DataSource = Adodc1
End If
End Sub

Private Sub Command2_Click()
Dim query As String
query = "select*from (车位信息)"
Adodc1.RecordSource = query
If query <> "" Then
Option1.Value = False
Adodc1.Refresh
End If
Set rsgrid.DataSource = Adodc1
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Dim rs As New ADODB.Recordset
Private Sub Form_Load()

Call fresh
End Sub
Private Sub fresh()
Dim strquery, sql As String
strquery = "select * from 车位信息"
Adodc1.RecordSource = strquery
Adodc1.Refresh
Set rsgrid.DataSource = Adodc1
rsgrid.Refresh
Option1.Value = False
End Sub

Private Sub Text1_Change()
Option1.Value = True
Call setSQL
Adodc1.RecordSource = Trim(query)
Adodc1.CommandType = adCmdText
Adodc1.Refresh
Set rsgrid.DataSource = Adodc1
End Sub
Private Sub setSQL()
If Option1.Value Then
If Text1.Text <> "" Then
query = "select * from 车位信息 where left(cwtype," & Len(Text1.Text) & ")='" & Trim(Text1.Text) & "'"
Else
MsgBox "请输入你要查找的车位区域"
End If
End If

End Sub

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!