RushiShroff
Programmer
Here I want to do data access from COM.
I have a ready made code HowToProject3 from
Project Name : How2Project3
Class Name : ClassName
well they have given ready made compiled dll for this named
ProjectName3.dll
My question is while instantiating a component as an object, generally we write server.createObject("Project.ClassName"
So can we give any name to dll after compilation ?
I mean (after that will register it to the directory),name of dll matters or NOT ??.
In my ASP page
My next question is if array is found to be empty, how can I trap it ??
Rushi Shroff Rushi@emqube.com
"Life is beautiful."
I have a ready made code HowToProject3 from
Project Name : How2Project3
Class Name : ClassName
Code:
Public Function MethodName(ByVal strDbConnectionString As String, _
ByVal strSQL As String) As Variant
'~~~~~~~~~~~~~ Set ADO objects ~~~~~~~~~~~~~~~~~~
Dim oRs As New ADODB.Recordset
Dim oCmd As New ADODB.Command
Dim oConn As New ADODB.Connection
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~ Open Database with method argument ~~~~~~
oConn.Open strDbConnectionString
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~ Assign values to ADO objects ~~~~~~~~~
oCmd.CommandText = strSQL
oCmd.CommandType = adCmdText
Set oCmd.ActiveConnection = oConn
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~ Open the RecordSet ~~~~~~~~~~~~~~~
oRs.Open oCmd
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~Assign RecordSet to Variant Array ~~~~~~~
MethodName = oRs.GetRows
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~Close RecordSet/Connection ~~~~~~~~~~~~~~~~
oRs.Close
oConn.Close
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~ Set objects to nothing ~~~~~~~~~~~
Set oRs = Nothing
Set oCmd = Nothing
Set oConn = Nothing
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End Function
well they have given ready made compiled dll for this named
ProjectName3.dll
My question is while instantiating a component as an object, generally we write server.createObject("Project.ClassName"
So can we give any name to dll after compilation ?
I mean (after that will register it to the directory),name of dll matters or NOT ??.
In my ASP page
Code:
<%
'-----~~~~~- Record Field Constants ~~~~~~~~~~~~~
Const EXAMPLE_FIELD_ID = 0 '<- ExampleFieldID
Const EXAMPLE_FIELD_1 = 1 '<- ExampleField1
Const EXAMPLE_FIELD_2 = 2 '<- ExampleField2
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~~~~~~ Set Object ~~~~~~~~~~~~~~~~~
Set oClass = Server.CreateObject("How2Project3.ClassName")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~ Set method patameters ~~~~~~~~~~~~~
strDbConnectionString = "strDSN"
strSQL = "Select ExampleFieldID, ExampleField1, ExampleField2 FROM ExampleTable"
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~ Get RecordSet Variant Array ~~~~~~~~~
vRecordArray = oClass.MethodName(strDbConnectionString, strSQL)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'~~~~~~~~~~~~~ Set Object to Nothing ~~~~~~~~~~~~
Set oClass = Nothing
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%>
<HTML><HEAD><TITLE>How2 EXAMPLE</TITLE></HEAD><BODY>
Number of records returned is <%=UBound(vRecordArray, 2) + 1%><BR>
<TABLE BORDER="1" CELLSPACING="3">
<%lngUBound = UBound(vRecordArray, 2) %>
<%For lngIndex = 0 to lngUBound %>
<TR>
<TD><%=vRecordArray(EXAMPLE_FIELD_ID, lngIndex)%></TD>
<TD><%=vRecordArray(EXAMPLE_FIELD_1, lngIndex)%></TD>
<TD><%=vRecordArray(EXAMPLE_FIELD_2, lngIndex)%></TD>
</TR>
<%Next%>
</TABLE>
</BODY></HTML>
My next question is if array is found to be empty, how can I trap it ??
Rushi Shroff Rushi@emqube.com
"Life is beautiful."