有没有人会用vb连接oracle数据库啊!

解决方案 »

  1.   

    首先要引用ADO工程库:工程-〉引用-〉点选 Microsoft ActiveX Data Objects 2.x Library程序中使用如下代码就可以了:
        
        Dim adoconn As New ADODB.Connection
        Dim adorst As New ADODB.Recordset
        adoconn.Open "Provider=MSDAORA.1;Password=testpassword;User ID=testid;Data Source=testhostname;Persist Security Info=True"
        
        adorst.Open "select * from table1", adoconn
        Set adorst = Nothing
        Set adoconn = Nothing
      

  2.   

    我刚学会,互相指教,说一种我用得最烂的。
    在ODBC 的系统DSN里设置好ORACLE的连接,测试成功
    打开VB然后菜单-》Project->components->选中Microsoft ADO data Control6.0和Microsoft Datagrid control6.0然后确定
    建一个FORM然后在FORM里建一个ADODC,adodc1的属性如下
    connectionstring:dsn=gdy
    password:gdy
    RecordSource:select * from all_objects
    username:gdy
    然后建datagrid,属性如下
    datasource=adodc1
    运行!
    成功感如何?没有?呵,可能我写错了,对不起。