ASP mssql数据库连接代码

[浏览132]
On Error Resume Next
Const DataType="Access"        '数据库类型
if DataType="Access" then
   dim ConnStr,Conn,datapath,SqlDatabaseName,SqlPassword,SqlUsername,SqlLocalName
   datapath="../QUCHUNLIN/#mygod168188.MDB"
   connstr="Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & Server.mappath(datapath)
   Set conn=Server.CreateObject("ADODB.Connection")
   conn.open connstr   
   else
SqlDatabaseName = "fangwei"      'SQL数据库名
SqlPassword = "123456"              'SQL数据库用户密码
SqlUsername = "brookqcl"               'SQL数据库用户名     
SqlLocalName = "(local)"    'SQL主机IP地址(本地可用“127.0.0.1”或“(local)”,非本机请用真实IP)
ConnStr = "Provider = Sqloledb; User ID = " & SqlUsername & "; Password = " & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source = " & SqlLocalName & ";"
Set conn = Server.CreateObject("ADODB.Connection")
   conn.open ConnStr
 sub CloseConn()
conn.close
set conn=nothing
 end sub
 end if 

关闭 ]
友情链接

Copyright © 2014 ASP技巧教程源码大全 All Rights Reserved
晋ICP备14006235号-3 页面执行时间:77.148毫秒 返回顶部