asp如何连接sqlserver2005
最近换了一个sql2005的数据库,以前连接2000数据库的代码现在不能用了,那位知道如何用asp代码连接sql2005,最好给些代码参考一下。多谢拉!!!!!
'==== VBScript ===
Dim hConn
Set hConn = Server.CreateObject("ADODB.Connection")
With hConn
.ConnectionTimeout = 25
.Provider = "SQLOLEDB"
.Properties("Data Source").Value = "計算機名字\SQLEXPRESS"
.Properties("Initial Catalog").Value = "數據庫名稱"
.Properties("Integrated Security").Value = "SSPI"
End With
hConn.Open
....
...
...
hConn.Close
Set hConn = Nothing
// ============ JScript =========
var hConn = Server.CreateObject("ADODB.Connection");
hConn.ConnectionTimeout = 25;
hConn.Provider = "SQLOLEDB";
hConn.Properties("Data Source").Value = "計算機名稱\\SQLEXPRESS";
hConn.Properties("Initial Catalog").Value = "數據庫名稱";
hConn.Properties("Integrated Security").Value = "SSPI";
hConn.Open();
......
.....
.....
hConn.Close();
delete hConn;