asp怎么和MSSQL数据库连接啊
2015-12-11 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
asp连接mysql的核心代码如下:
Set Conn=Server.CreateObject("ADODB.Connection") //采用ADO方式连接
servername="XINZHI-SERVER" //连接server名
dbname="User_info" //连接数据库
StrConn="Driver={ mysql odbc 3.51 driver};Server=(localhost);DataBase=hr;Uid=root;Pwd=root" //配置驱动
Conn.open strConn //打开连接
if err then //如果连接出错的处理
err.Clear
Set Conn = Nothing
Response.Write "数据库正在调整中,请稍候再试。"
Response.End
end if
Set Conn=Server.CreateObject("ADODB.Connection") //采用ADO方式连接
servername="XINZHI-SERVER" //连接server名
dbname="User_info" //连接数据库
StrConn="Driver={ mysql odbc 3.51 driver};Server=(localhost);DataBase=hr;Uid=root;Pwd=root" //配置驱动
Conn.open strConn //打开连接
if err then //如果连接出错的处理
err.Clear
Set Conn = Nothing
Response.Write "数据库正在调整中,请稍候再试。"
Response.End
end if
展开全部
Dim Conn,ConnStr,DataServer,DataBase,DataUser,DataPass
DataServer = "xxxxxx" //服务器IP
DataBase = "xxxxxx" //数据库名
DataUser = "xxxxxx" //用户名
DataPass = "xxxxxx" //密码
ConnStr="Provider=SQLOLEDB.1;User ID="&DataUser&";Password="&DataPass&";Initial Catalog="&DataBase&";Data Source="&DataServer&""
Set conn=Server.CreateObject("ADODB.Connection")
conn.ConnectionString=ConnStr
conn.Open
DataServer = "xxxxxx" //服务器IP
DataBase = "xxxxxx" //数据库名
DataUser = "xxxxxx" //用户名
DataPass = "xxxxxx" //密码
ConnStr="Provider=SQLOLEDB.1;User ID="&DataUser&";Password="&DataPass&";Initial Catalog="&DataBase&";Data Source="&DataServer&""
Set conn=Server.CreateObject("ADODB.Connection")
conn.ConnectionString=ConnStr
conn.Open
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<%
set cnn=server.CreateObject("adodb.connection")
cnn.open "provider=sqloledb;data source=121.198.44.40;uid=1;pwd=1;database=cn21059_db"
%>
uid 是数据账号 sa pwd是密码 cn21059_db是数据库名称
set cnn=server.CreateObject("adodb.connection")
cnn.open "provider=sqloledb;data source=121.198.44.40;uid=1;pwd=1;database=cn21059_db"
%>
uid 是数据账号 sa pwd是密码 cn21059_db是数据库名称
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
给你完整的asp连接SQL语句
<%
Const SqlDatabaseName = "数据库名称"
Const SqlPassword = "密码"
Const SqlUsername = "用户名"
Const SqlLocalName = "服务器id"
Sub ConnectionDatabase
Dim ConnStr
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"" /><div style=""font-size:12px;font-weight:bold;border:1px solid #006;padding:6px;background:#fcc"">数据连接出错</div>"
Response.End
End If
End Sub
%>
<%
Const SqlDatabaseName = "数据库名称"
Const SqlPassword = "密码"
Const SqlUsername = "用户名"
Const SqlLocalName = "服务器id"
Sub ConnectionDatabase
Dim ConnStr
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"" /><div style=""font-size:12px;font-weight:bold;border:1px solid #006;padding:6px;background:#fcc"">数据连接出错</div>"
Response.End
End If
End Sub
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询