Use component package database operation

zhaozj2021-02-16  124

VB6 code:

-------------------------------------------------- ---

PRIVATE CONN As Adodb.Connection

Private rs as adodb.recordset

'Role: Determine if the database is properly connected

Public function getConn () as boolean

??? set conn = new adodb.connection ??? ??? conn.open "provider = abc.mdb" ??? ??? if err.number <> 0 THEN? ??????? GetConn = false ??????? ??? Else ??? ??????? getConn = True ??????? ??? end if ??? end function

'Get record according to the input ID

Public Function GetName (Strid As Integer) AS String

??? DIM strsql as string ??? ??? set = new adodb.recordset ??? ??? strsql = "select * from [user] where userid =" & strid ??? ??? ropen Strsql, conn, adopenstatic, adLockbatchoptimistic ??? ??? if xi e ??? ??????? getname = "" ??????? ??? Else ??? ???? ??? getname = rs.fields (0) ??????? ??? End if ??? ??? rs.close ??? End Function

Public function closedb ()

??? conn.close ??? End function

?

ASP call component code:

-------------------------------------------------- ---

<% Dim DataQuerydim Striddim Strresultdim Flag

Set DataQuery = Server.createObject ("Webdb.GetInfomation")

Flag = DataQuery.getConn ()

Response.write flag & ""

Response.write dataQuery.getname (10)

DataQuery.closedb ()

SET DATAQUERY = Nothing

%>

转载请注明原文地址:https://www.9cbs.com/read-13389.html

New Post(0)