/ * Written by Jaron, 2003-05-10 * // * Original: Jiangdu Information Network http://www.jiangdu.net * // * Reprint Please indicate the source and keep this copyright information * // * Welcome SiteManager website management system http://sitemanager.cnzone.net * /
VB-Engineering - Reference - ADO 2.0, build a class DB, the project is set to SQLConn below is part of the doll program, everyone can try Option Explicitpublic Strerror AS STRINGPUBLIC CONN AS New AdoDB.ConnectionPublic RS AS New AdoDB. RecordsetPublic Property Get ErrorString () As StringErrorString = strErrorEnd PropertyPublic Function Conn_Open (strSQLServerName, strSQLDBUserName, strSQLDBPassword, strSQLDBName) Dim strCon As StringSet Conn = New ADODB.ConnectionOn Error GoTo errHandler: strCon = "Provider = SQLOLEDB; Server =" & strSQLServerName & " User ID = "& strsqldbusername"; password = "& strsqldbpassword"; database = "& strsqldbname"; "conn.open strconerrhandler: strerror =" error Source: "& Err.Source & Vbcrf &" Description: " & Err.DescriptionExit FunctionEnd FunctionFunction getRootID (ByVal ClassID) Dim queryquery = "select class_ID, RootID from tblCategory where class_id = '" & ClassID & "'" Set Rs = Conn.Execute (query) If Not (rs.EOF And Rs. BOF) THENGETROOTID = RS ("rootid") ElseGetrootid = ClassidEnd IFRS.Closset RS = Nothingend Function compiles, in ASP, use Function Gtrootid (ByVal) id) 'get the root class ID number set S_DB = server.CreateObject ( "SQLCONN.DB") S_DB.Conn_Open strSQLServerName, strSQLDBUserName, strSQLDBPassword, strSQLDBNameGetRootID = S_DB.GetRootID (id) Set S_DB = nothingend function