平台:vb6.0,access2000。用ado打开数据库Private Sub Command1_Click()
'定义ado变量
Dim adocon As Connection
Dim rsado As Recordset
'打开数据库
Set adocon = New Connection
adocon.CursorLocation = adUseClient
adocon.Open "Provider=Microsoft.jet.OLeDB.4.0;Data Source=" & App.Path & "\dbriver.mdb;"然后应该如何读取数据库中的数据?
我是这样写的:
rsado = adocon.Execute (select * from db1 where name=选择值)
报错:缺少表达式我的vb学得不是很好,特别是关于数据库的以前没有学过。
rsado = adocon.Execute (select * from db1 where name=选择值)
我是仿照asp中的经验来的(大虾们不要笑!!!)
================================================
建立一个搜索数据库的数据集合请问vb中应该怎么写?
================================================
谢谢啦,谢谢各位大虾解答我的问题。

解决方案 »

  1.   

    set rsado = adocon.Execute (select * from db1 where name=选择值)
      

  2.   

    在ASP中也不是这样了.
    出了上面朋友的方法外.
    还可以
    dim RSado as new adodb.recordset
    rsado.open "select * from db1 where name=选择值",adocon
      

  3.   

    记住声明了对象变量以后一定要new以后才能使用.使用方法 一楼和二楼的两个都是可行的.
      

  4.   

    rsado = adocon.Execute (select * from db1 where name=选择值)
    改为:Set rsado = adocon.Execute (select * from db1 where name=选择值)给对象变量赋值时要加上SET.
      

  5.   

    补充:
    所有的SQL语句都是字符串,所以变量等都得转换为字符串
    上面的应该写成
    Set rsado = adocon.Execute ("select * from db1 where name='" & 选择值 & "'")may be help