我要访问的是远程sybase数据库,我的机子上已经做好配置,并能通过access访问数据库,浏览数据库中的各个数据表内容。
现在我要用vb访问该数据库,是不是要先写连接数据库的代码?通过看参考书,我写了下面的代码:
dim cnadonetconnection as new oledb.oledbconnection()/创建oledbconnection变量并将其初始化为新连接
private m_cnadonetconnection as new oledb.oledbconnection()/创建一个模块级变量存储连接
m_cnadonetconnection.connectionstring=
"provider=sybase system11;data sourse=mta;user id="mta_com_usr";password="mta_com_usr2k""/指定要连接的数据源m_cnadonetconnection.open()/使用连接对象的open()方法建立到数据源的连接这样是否正确? 
其中data sourse是要指明要连接的数据库的名称,书上的例子是数据库的安装位置,如“c:\temp”
那我要连接的数据库并没装在本机,该写什么呢?
看书上和网上,说法各种各样,我都糊涂了。请各位大虾帮帮忙啊!

解决方案 »

  1.   

    dim cn as new adodb.connection
    dim rs as new adodb.recordset
    private sub form_load()
    cn.open="provider=sybase system11;data sourse=mta;user id="mta_com_usr";password="mta_com_usr2k""
    end sub这段代码呢?
      

  2.   

    安装sybase的客户端,用ADODC控件连,看能否连通,不通的话只能使用ODBC
      

  3.   

    OLEDB:-Adaptive Server Enterprise (ASE) with Data Source .IDS file:  "Provider=Sybase ASE OLE DB Provider; Data source=myASE"   Note: you must create a Data Source .IDS file using the Sybase Data Administrator. These .IDS files resemble ODBC DSNs. -Adaptive Server Enterprise (ASE):  "Provider=Sybase.ASEOLEDBProvider;Srvr=myASEserver,5000;Catalog=myDBname;User Id=username;Password=password"    - some reports on problem using the above one, try the following as an alternative -  "Provider=Sybase.ASEOLEDBProvider;Server Name=myASEserver,5000;Initial Catalog=myDBname;User Id=username;Password=password"   This one works only from Open Client 12.5 where the server port number feature works, allowing fully qualified connection strings to be used without defining any .IDS Data Source files.