[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLOLEDB.1;Password=pwd;Persist Security Info=True;User ID=sa;Initial Catalog=db;Data Source=dbserver
將上面的文字另存成conn.udl即可.
上面是udl文件內容,前臺和下面的組件操作數據庫時都是通過它來聯接的.
2,用vb編寫組件在服務器上註冊,組件內容主要是來完成業務邏輯.
3,在前asp中主要用於顯示.
說明:
在vb工程文件中連接udl
Function UTL_Connect() As Boolean
'資料庫連結
UTL_Connect = True
Dim sConString As String
On Error GoTo ErrConnect
sConString = "File Name=" + App.Path & "\Conn.udl"
Set adoCnn = New ADODB.Connection
adoCnn.ConnectionTimeout = 240
adoCnn.Open sConString
adoCnn.CommandTimeout = 240
Exit Function
ErrConnect:
UTL_Connect = False
Err.Raise Err.Number, SetErrSource("", "Globals.UTL_Connect"), "資料庫連結失敗!"
End Function
'資料庫連結
UTL_Connect = True
Dim sConString As String
On Error GoTo ErrConnect
sConString = "File Name=" + App.Path & "\Conn.udl"
Set adoCnn = New ADODB.Connection
adoCnn.ConnectionTimeout = 240
adoCnn.Open sConString
adoCnn.CommandTimeout = 240
Exit Function
ErrConnect:
UTL_Connect = False
Err.Raise Err.Number, SetErrSource("", "Globals.UTL_Connect"), "資料庫連結失敗!"
End Function
ado聯接udl
Function Opendb()
Application.Lock
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionTimeout = 600
conn.open("file name=" + server.MapPath("conn.udl"))
'conn.open "FILE Name=C:\SecureStuff\MyDataLink.UDL"
conn.CommandTimeout = 1500
Set Opendb = conn
Application.UnLock
End Function
Application.Lock
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionTimeout = 600
conn.open("file name=" + server.MapPath("conn.udl"))
'conn.open "FILE Name=C:\SecureStuff\MyDataLink.UDL"
conn.CommandTimeout = 1500
Set Opendb = conn
Application.UnLock
End Function