您的位置首页百科问答

求一个asp数据库连接的代码conn.asp

求一个asp数据库连接的代码conn.asp

<%@ LANGUAGE = VBScript CodePage = 936%><%Option ExplicitResponse.Buffer = TrueDim StartimeDim SqlNowString,Dvbbs,template,MyBoardOnlineDim Conn,Plus_Conn,Db,MyDbPathConst fversion="7.1.0 Sp1"Const EnabledSession= TrueStartime = Timer()'系统采用XML版本设置'最高版本为.4.0 依次为: Const MsxmlVersion=".3.0" Const MsxmlVersion=".2.6" 最低版本Const MsxmlVersion=""Const MsxmlVersion=".3.0"'可修改设置一:========================定义数据库类别,1为SQL数据库,0为Access数据库=============================Const IsSqlDataBase = 0MyDbPath = ""'================================================================================================================If IsSqlDataBase = 1 Then'必修改设置二:========================SQL数据库设置============================================================='sql数据库连枯伏接参数:数据库名(SqlDatabaseName)、用户密码(SqlPassword)、用户名(SqlUsername)、'连颤败唯接名(SqlLocalName)(本地用local,外地用IP)Const SqlDatabaseName = "dvbbs"Const SqlPassword = "dvbbs"Const SqlUsername = "dvbbs"Const SqlLocalName = "(local)"SqlNowString = "GetDate()"ElseSqlNowString = "Now()"End IfConst IsDeBug = 1Set Dvbbs = New Cls_ForumSet template = New cls_templatesSub ConnectionDatabase Dim ConnStr If IsSqlDataBase = 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(MyDbPath & db) End If On Error Resume Next Set conn = Server.CreateObject("ADODB.Connection") conn.open ConnStr If Err Then err.Clear Set Conn = Nothing Response.Write "数据库连接出错,请检查连接字串。"'注释,需要把这几个字翻译成英文 Response.End End IfEnd Sub%>动网的。仅供参考