我公司的数据库服务器原来是本地的,所以公司内部的应用程序都是用VB6开发的基于本地数据库连接的。
现在公司要把数据库服务器搬到别的地方,只可能通过Internet连接,有什么办法只更改数据库的操作部分达到继续使用现有系统的目的吗?就是说,怎样能通过ADO连接远程的数据库呢?还有就是如果数据库在防火墙后面怎么办?

解决方案 »

  1.   

    本来和局网没什么不同,就是重试时间设置稍长。服务器一定要有公网独立IP,这样比较方便。如果在内网,有防火墙的话,需要找网管映射端口,这个端口要和SQL-Server的端口一致。设置成功后,其它的操作和在局网里面一样的简单。
      

  2.   

    Connect via an IP address:
    "Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;" 
    (DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default))
      

  3.   

    补充: How to define wich network protocol to use Example: "Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;" Name Network library dbnmpntw Win32 Named Pipes dbmssocn Win32 Winsock TCP/IP dbmsspxn Win32 SPX/IPX dbmsvinn Win32 Banyan Vines dbmsrpcn Win32 Multi-Protocol (Windows RPC) Important note! When connecting through the SQLOLEDB provider use the syntax Network Library=dbmssocn and when connecting through MSDASQL provider use the syntax Network=dbmssocn
      

  4.   

    Option Explicit
    Dim cnn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sql As StringSet cnn = New ADODB.Connection
    cnn.CursorLocation = adUseClient
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\ServerName\databasename"
    sql = "select * from tablename"
    Set rs = New ADODB.Recordset
    rs.Open sql, cnn
    Set DataGrid1.DataSource = rs
    set rs=nothing
    set cnn=nothing
      

  5.   

    ServerName:服务器名
    databasename:服务器上的数据库