ASP快速开发方法之数据操作
2007-08-08 12:05:40 来源:WEB开发网那我再改进下:
把conn.asp文件改成:<%
Dim Conn
Dim Rs
Sub CloseDatabase
Conn.close
Set Conn = Nothing
End Sub
Sub OpenDatabase
Dim StrServer,StrUid,StrSaPwd,StrDbName
StrServer="192.168.1.1" '数据库服务器名
StrUid="sa" '您的登录帐号
StrSaPwd="" '您的登录密码
StrDbName="cnbruce.mdb" '您的数据库名称
Set Conn = Server.CreateObject("ADODB.Connection")
'用于连接ACCESS
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath(StrDbName)
'用于连接MSSQL
'Conn.ConnectionString = "Driver={sql server};driver={SQL server};server="&StrServer&";uid="&StrUid&";pwd="&StrSaPwd&";database=
"&StrDbName
set rs=server.CreateObject("ADODB.RecordSet")
conn.open
if Err Then
err.Clear
Set Conn = Nothing
GBL_CHK_TempStr = GBL_CHK_TempStr & "数据库连接错误!"
Response.Write GBL_CHK_TempStr
Response.End
End If
End Sub
%>
更多精彩
赞助商链接