采用 Windows 認證方式看下:
Dim m_hConn
Set m_hConn = Server.CreateObject("ADODB.Connection")
Call SQLConnect("127.0.0.1", "home181", False)
Public Sub SQLConnect(ByVal lpszServerName, ByVal lpszDBName, ByVal bIsSQL2005)
On Error Resume Next
Call ReleaseConnection()
m_hConn.ConnectionTimeout = 25
m_hConn.Provider = "SQLOLEDB"
If bIsSQL2005 Then
m_hConn.Properties("Data Source").Value = lpszServerName & "\SQLEXPRESS"
Else
m_hConn.Properties("Data Source").Value = lpszServerName
End If
m_hConn.Properties("Initial Catalog").Value = lpszDBName
m_hConn.Properties("Integrated Security").Value = "SSPI"
m_hConn.Open
' 你可以不要以下這段了
'If Err.Number <> 0 Then
'
Call PrintError("IDatabase::SQLConnect")
'
Exit Sub
'End If
'Set m_hCmd.ActiveConnection = m_hConn
End Sub
原來朋友仔感情再天真, 亦是我永遠也會愛惜的人, 明日愛他人, 也記住學會不要緊; 原來朋友比戀人更高分, 亦讓我開始懂得不記恨, 若大家都敏感, 我更要永遠記得拒絕再因小事怪人, 爲何沒有這條校訓...Twins-朋友仔
MCSD Training