charon
08-16-2002, 12:54 PM
Hi, I don't know whether this forum allow to ask question about Component Object or not. Anyway I just try it.
As we all know that, COM is to facilitate code reuse, and methods for extending applications. Now, intead of writting long VB script into an asp page, a lot of web programmer already adopt COM technology for writting COM object and call it via ASP. This is not only for code reuse but fastert processing.
I'm a beginner in writting component, have alreday gone through some of the tutorial and sample about writting component. Now, intend to write a very simple Database Connection Component by using Visual Basic, but don't know how to start.
Normally, I will create an include file for database connection, as listed below:
<!-- #Include file="ADOVBS.INC" -->
<% Response.Buffer = true %>
<%
Session.Timeout=720
' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30
'Use this line to use Access
objDC.Open "DBQ=" & Server.MapPath("/intra/data/launchregister.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20;uid=;pwd=1234"
' Create recordset and retrieve values using the open connection
Set objRS = Server.CreateObject("ADODB.Recordset")
with objRS
.ActiveConnection = objDC
.CursorLocation = adUseClient
.CursorType=adOpenDynamic
.LockType=adLockOptimistic
end with
%>
So now, intead of creating include file, I want to create a simple connection component. Please help!
Thanks so much...
As we all know that, COM is to facilitate code reuse, and methods for extending applications. Now, intead of writting long VB script into an asp page, a lot of web programmer already adopt COM technology for writting COM object and call it via ASP. This is not only for code reuse but fastert processing.
I'm a beginner in writting component, have alreday gone through some of the tutorial and sample about writting component. Now, intend to write a very simple Database Connection Component by using Visual Basic, but don't know how to start.
Normally, I will create an include file for database connection, as listed below:
<!-- #Include file="ADOVBS.INC" -->
<% Response.Buffer = true %>
<%
Session.Timeout=720
' Create and establish data connection
Set objDC = Server.CreateObject("ADODB.Connection")
objDC.ConnectionTimeout = 15
objDC.CommandTimeout = 30
'Use this line to use Access
objDC.Open "DBQ=" & Server.MapPath("/intra/data/launchregister.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;MaxBufferSize=8192;Threads=20;uid=;pwd=1234"
' Create recordset and retrieve values using the open connection
Set objRS = Server.CreateObject("ADODB.Recordset")
with objRS
.ActiveConnection = objDC
.CursorLocation = adUseClient
.CursorType=adOpenDynamic
.LockType=adLockOptimistic
end with
%>
So now, intead of creating include file, I want to create a simple connection component. Please help!
Thanks so much...