|
|
 |
| Classic ASP Components Discussions specific to components in ASP 3. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Components section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |
|

June 5th, 2003, 04:59 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Creating Activex DLL components
Hi there
I have been looking into find some pages with tutorials/artikles on creating DLL components but have not been able to find any. Can someone give me some links to that or give me an example on how to create Dll's ?
/vbmo
|

June 5th, 2003, 09:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|

June 6th, 2003, 04:32 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok thanks But if there should be some tutorials/artikles on using Sql in the dll i would like those to :o)
/vbmo
|

June 6th, 2003, 02:55 PM
|
 |
Wrox Author
Points: 33,554, Level: 80 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
|
|
Hi vbmo,
What exactly are you looking for? If I recall correctly, Microsoft has created a sample application using a VB DLL for a common Data Access Layer with methods like ExecuteSprocGetRecordSet, ExecuteSQLetc. I searched google for this, but couldn't find it anymore.
The company I work for has used this example to create our own DAL, so if you have any specific questions, feel free to ask.
Cheers,
Imar
|

June 6th, 2003, 05:45 PM
|
|
Registered User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar
I am simply looking for some toturials/artikles on creating dll's using VB. But the part with the "Hello World" is not enough i want to learn how to include sql and ado in my dll's :o)
/vbmo
|

June 7th, 2003, 08:17 AM
|
 |
Wrox Author
Points: 33,554, Level: 80 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
|
|
Hi vbmo,
I am sure there are a couple of tutorials / faqs on the net describing how to create a VB DLL using ADO, but I couldn't find one in my bookmarks. However, it's not too difficult. Using ADO in VB is more or less the same as in ASP. The biggest thing to watch for is passing parameters in and out of procedures. The type (strongly typed versus a Variant) of the parameters is important.
You can read more about that here: http://support.microsoft.com:80/supp...NoWebContent=1
OK, now for the "mini tutorial"
1. Start a new ActiveX DLL project and add a reference to the Microsoft ActiveX Data Objects 2.5/2.6
2. Create a property (type string) to hold the connection string. Alternatively, add the connection string as a hard coded value, although this is not recommended.
3. Add a method (a Sub) like ExecSproc with the following code:
Code:
Public Sub ExecSproc(ByVal NameOfSproc As String)
'===============================================================
' NAME: ExecSproc
' DATE CREATED:
' CREATED BY:
' CREATED FOR:
' FUNCTION: Executes a sproc that does not return any records
' IN: NameOfSproc. The name of the sproc to execute
' OUT: Nothing
' RETURNS: Nothing
' VERSION: 1
' EXAMPLE:
'===============================================================
On Error GoTo errorHandler
Dim connConnection As ADODB.Connection
Dim cmdCommand As ADODB.Command
Set connConnection = New ADODB.Connection
Set cmdCommand = New ADODB.Command
With connConnection
.Open YourConnectionString
End With
With cmdCommand
' Set command properties
.ActiveConnection = connConnection
.CommandType = adCmdStoredProc
.CommandText = NameOfSproc
End With
' Now execute without using a return value
With cmdCommand
.Execute , , adExecuteNoRecords
.ActiveConnection = Nothing
End With
' And clean up
Set cmdCommand = Nothing
Set connConnection = Nothing
Exit Sub
errorHandler:
If connConnection.State = adStateOpen Then
connConnection.Close
End If
Set cmdCommand = Nothing
Set connConnection = Nothing
End Sub
4. Compile the DLL and place it inside a COM+ package. See http://www.aspfree.com/authors/rober...ult.asp?aid=96 for more info on this.
5. Now you can use the DLL as follows in ASP:
Code:
Dim objDataAccess
Set objDataAccess = Server.CreateObject("MyProject.MyClassName")
objDataAccess.ExecSproc("sprocUpdatePrice")
Set objDataAccess = Nothing
As you can see, this is just a very short description of the situation. Of course you'll need more methods, properties etc to make this a successful Data Access component. Methods that you can implement are:
1. ExecSprocReturnRecordset - returns a strongly typed ADODB.Recordset
2. ExecSprocReturnArray - returns a Variant()
3. ExecSprocReturnInteger
4. ExecSQLReturnRecordset - accepts plain SQL instead of a sproc.
You'll also need a way to set up incoming parameters for the procedures.
All this code is based on the FMStocks sample site that Vertigo / Microsoft provided. If you go to http://www.fmstocks.com and download the FMStock 2000 sample project, you'll find all the stuff you need.
It looks like it's time I write a tutorial on how to create a DAL using the FMStock sample as a basis ;)
Cheers,
Imar
|

June 10th, 2003, 02:56 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
That was very usefull thanks a lot :o) Then i have just one question left, when i run a DLL under COM+ do i then not have to restart IIS when i compile my DLL again if there should be a bug in it ?
|

June 10th, 2003, 03:23 AM
|
 |
Wrox Author
Points: 33,554, Level: 80 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,228
Thanks: 7
Thanked 203 Times in 201 Posts
|
|
Hi there,
You don't have to restart IIS ever when using COM+ (well, under normal circumstances that is. Sometimes it hangs and needs to be restarted anyway).
Even if you fix a bug all you need to do is follow the steps in the FAQ I posted.
You should also take some time to understand the GUID principle behind COM+ DLLs. If you don't make changes to the interface of your component (add / remove methods, add / remove parameters to existing methods etc) then the GUID for your component stays the same and your component is said to be binary compatible. If you do change the interface, a new GUID is assigned and your component might break (when used in other components / applications).
In both cases, you'll need to stop the package in COM+, remove the components from the package, replace the DLL and then add them again.
HtH
Imar
|

June 10th, 2003, 08:27 AM
|
|
Registered User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok thats nice to know thanks for your help :o)
And in the meantime i have found this one just if you want to read it, it is also a nice artikle : http://www.asp101.com/articles/carvi...ss/default.asp
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |