Private Sub Optinformation_Click(Index As Integer)
Dim s As String
Select Case Index
Case 0
s = InputBox("请输入要查询的驾龄:")
Adodc1.RecordSource = "select * from 交通事故信息 where 驾龄 like '%" & s & " % ' "
Adodc1.Refresh
DataGrid1.Refresh
Case 1
s = InputBox("请输入要查询的违章行为:")
Adodc1.RecordSource = "select * from 交通事故信息 where 违章行为 like '%" & s & " % ' "
Adodc1.Refresh
DataGrid1.Refresh
Case 2
s = InputBox("请输入要查询的事故时间:")
Adodc1.RecordSource = "select * from 交通事故信息 where 事故时间 like '%" & s & " % ' "
Adodc1.Refresh
DataGrid1.Refresh
Case 3
s = InputBox("请输入要查询的性别:")
Adodc1.RecordSource = "select * from 交通事故信息 where 性别 like '%" & s & " % ' "
Adodc1.Refresh
DataGrid1.Refresh
End Select
End Sub

解决方案 »

  1.   

    可能需要事先注册Iadodc依赖的控件。在64位Windows下:
    64位exe和dll在目录c:\windows\system32目录下;
    32位exe和dll在目录c:\windows\syswow64目录下;
    所以要注意:
        在win64位系统下注册32位ocx或dll需要将32位ocx或dll拷贝到c:\windows\syswow64\目录下。
        且注册要用c:\windows\syswow64\regsvr32 xxxxxxx.ocx或dll
        在win64位系统下设置32位程序使用的数据库别名要用c:\windows\syswow64\cliconfg.exe
        在win64位系统下设置32位程序使用的系统DSN要用c:\windows\syswow64\odbcad32.exe
      

  2.   

    Adodc1是什么类型的变量?
      

  3.   

    adodc的连接字符串呢?
      

  4.   

    SQL语句中的字段均是字符型数据类型,就没有问题。
    DataGrid1.Refresh 好像不对,应该是:
    Set DataGrid1.DataSource = Adodc1   '在DataGrid1中显示数据