asp数据连接代码
<!--#include file="system.asp" -->
<%
'如果使用国外主页空间,请使用下面语句:'
'rem codepage="936" '
sqlkai=0
Dim SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
SqlLocalName="(local)"
SqlUsername="nntoa"
SqlPassword="123456"
SqlDatabaseName="sqloa"
dim conn
dim connstr
dim db
'更改数据库名字'
if db="" then db="nntdata/mynntdata.mdb"
on error resume next
Set conn = Server.CreateObject("ADODB.Connection")
if err then
err.clear
Response.Write("<BR><li>操作失败,无法创建数据库对象!")
response.end
end if
if sqlkai=1 then
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
else
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")&";Jet OLEDB:Database password="&nt80acmi&""
end if
conn.Open connstr
if err then
err.clear
Response.Write("<BR><li>操作失败,无法创建数据库连接!")
response.end
end if
function connClose'关闭数据库
Conn.close
Set conn = Nothing
End Function
%>
<!--#include file="f_md5.asp" --><!--#include file="f_text.asp" -->
补充:asp教程,ASP入门