当前位置:数据库 > SQLServer >>

mssql数据库连接程序

mssql数据库连接程序

<%@ LANGUAGE = VBScript CodePage = 936%>
<!--#include file="safe.asp" -->
<%
On Error Resume Next
Response.Buffer = True
dim startime
dim conn
dim connstr
dim sqldatabase,sql_pass_word,sql_User_ID,sql_Data_Source
startime=timer()
Set conn = Server.CreateObject("ADODB.Connection")
connstr = "Provider=SQLOLEDB.1;Password='';Persist Security Info=False;User ID='sa';Initial Catalog='m1';Data Source='127.0.0.1'"
conn.Open connstr
'ConnStr = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Data Source=(local)"
'conn.Open connstr
'conn.DefaultDatabase = "dgjob"
Sub CreateRS(sql,lv1,lv2)
   set rs=server.CreateObject("adodb.recordset")
   rs.open sql,conn,lv1,lv2
End sub

function CloseDb
 Conn.close
 Set conn = Nothing
End Function

If Err Then
 Response.Write "<!--" & Err.Number & ":" & Err.Description & "-->" & vbcrlf
 Response.Write "<!--" & conn.ConnectionString & "-->" & vbcrlf
 Response.Write "数据库连接出错,请检查连接字串。"'注释,需要把这几个字翻译成英文。
 err.Clear
 Set Conn = Nothing
 Response.End
End If

 function rsclose
 set rs=nothing
 end function

 function connclose
 conn.close
 set conn=nothing
 end function

%>

<!---2147217843:用户 'cshrdb1' 登录失败。-->
<!--Provider=SQLOLEDB.1;Password='hncshr!@#$%';Persist Security Info=False;User ID='cshrdb1';Initial Catalog='m1';Data Source='127.0.0.1'-->
数据库连接出错,请检查连接字串。

补充:数据库,Mssql
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,