在程序中用Ado方式操作如下所示
Set gADO = New ADODB.Connection
gADO.ConnectionString = "File Name=" & App.Path & "\data.UDL;"
gADO.Open
If gADO.State <> adStateOpen Then GoTo errHandle
gOpenODBC = True
建立一个xxxx.udl类型的文件,其内容大致如下所示,在Win2000中双击能打开编辑、测试;到不同的机器上只需要双击打开此文件进行数据库连接测试即可。
[oledb]
; Everything after this line is an OLE DB initstring
Provider=MSDASQL.1;Password=password;Persist Security Info=True;User ID=elec_user;Mode=ReadWrite;Extended Properties="DRIVER=SQL Server;SERVER=127.0.0.1;UID=elec_user;APP=Microsoft(R) Windows (R) 2000 Operating System;WSID=127.0.0.1;DATABASE=elec;Network=DBMSSOCN";Initial Catalog=elec