|
-
Dec 10th, 2001, 07:58 AM
#1
Thread Starter
Addicted Member
Using dlls in website
Hi
I'm writing a web application that uses ASP to input/output data into several databases, and now need to access a DB that is custom built (and doesn't conform to SQL or standard connection procedures). I believe I need to call dlls to do this, but have no experience of doing this.
Could anyone help me out with a few questions:
1. What do I have to do in terms of establishing the dll on the server?
2. How do I call the dll from an ASP webpage?
3. Can I process results/variables from the dll in the ASP, or does everything have to be fully self-contained within the dll?
4. Are there any other issues or tips that I should be aware of (I have general VB knowledge but have never written a dll).
Thankyou
-
Dec 10th, 2001, 09:08 AM
#2
-
Dec 11th, 2001, 06:13 AM
#3
Thread Starter
Addicted Member
Thanks, should be helpful. I'll have a good look at it later.
-
Dec 13th, 2001, 10:00 AM
#4
Thread Starter
Addicted Member
Do I need to set references to the Microsoft Active Server Pages Object and Microsoft Transaction Server Type libraries? They are not present on my machine (linked to a server), and I can't find them on the server.
Cheers
-
Dec 13th, 2001, 10:04 AM
#5
nope !
for this to work, you won't need any refernces. Just make sure the dll's registered on your machine.
-
Dec 14th, 2001, 04:53 AM
#6
Thread Starter
Addicted Member
Thanks again. Just one more thing, then I (should) be away.
I've written my class module and saved the .vbp and .cls, and referred to these when setting the object in ASP. But how do I register on the server? I created a dll and ran regsvr32, is that right?
-
Dec 14th, 2001, 05:09 AM
#7
Code:
written my class module and saved the .vbp and .cls, and referred to these when setting the object in ASP
okey dokey, what you've got to do is turn this into a Dll first - like you create an exe file, under the file menu, theres an option "Mke YourProject.dll ..."
Once you have this file, yeah, at the start > run menu, type in REGSVR32 "C:\YourPath\YourFile.dll"
Also, can you tell me if you're running either winNT4 with the option pack installed or windows 2000 as there's an easier way to do this
-
Dec 14th, 2001, 05:24 AM
#8
Thread Starter
Addicted Member
The server's NT.
I created the dll, saved it on the server. I registered it and got the 'success' message. But I still get the "Can't create object" message at run time. I know I must be doing something wrong, like using the wrong server path or something. But it is registering the dll successfully somewhere.
Cheers
-
Dec 14th, 2001, 05:36 AM
#9
PowerPoster
hi
Just a check :
U saving the asp page on the same machine I guess!! and using
server.createobject("fdgdfg.dfsgdfg") method.
-
Dec 14th, 2001, 05:41 AM
#10
Thread Starter
Addicted Member
I am creating the ASP pages and dlls on my local PC, which has a server drive mapped to it. So I'm saving the stuff on the server.
Using server.createobject causes an "Invalid class string" message, while omitting the "server" bit causes a "Can't create object"
I'm guessing I'm doing something wrong with the registration. Do I have to do it on the actual server, or can I do it locally as I've been trying?
Thankyou.
-
Dec 14th, 2001, 05:47 AM
#11
PowerPoster
hi
Are u sure u have ADO 2.5 and above installed on your server???
if not then u can get it from http://www.microsoft.com/data
Though i am not exactly sure about it but I am looking
-
Dec 14th, 2001, 05:49 AM
#12
It must be the way your code is trying to reference it. There are 3 parts to creating this reference :
CREATEOBJECT(TestPro.TestCls)
- CREATEOBJECT - this funnily enough creates the object reference
 - The project name - not the dll name!
As attached, go to the project menu > properties & set this here. - The name of the class module
In your actual Dll, make your functions PUBLIC, and set the instancing property of the class to 5 so the ASP page can pick it up.
I.e. If I set this dll up with the project name "projectTest", and have 1 class module "classTest", I'd use :
Code:
'In Dll
Public function AreturnedString() as String
AreturnedString = "Hello World"
End Function
'In ASP page
Dim myProRef, MyClassRef
Set myProRef = CreateObject(projectTest.classTest)
Set MyClassRef = myProRef.AreturnedString
Msgbox MyClassRef
Set MyClassRef = nothing
Set myProRef = nothing
-
Dec 14th, 2001, 05:51 AM
#13
Whoops, this is what I'm going on about ...
-
Dec 14th, 2001, 06:09 AM
#14
Thread Starter
Addicted Member
Ok, here's what I've got:
I've got my project, with its name set to dllProj, and the class module called dllClass.
The class contains a ridiculously simple function (which, come to think of it, is probably where the problem is )...
I just want to get a variable from my ASP page, change it and pass it back to the ASP*
*bare in mind that I'm just trying to get a dll to work before playing with my real aims.
Anyway, the error occurs at the line setting the dll object in the ASP:
Code:
Set dllSet = CreateObject("dllProj.dllClass")
-
Dec 14th, 2001, 06:15 AM
#15
PowerPoster
Sort of looks okay to me.
Can u run other server.createobject functions porperply ? or do u get the same errror?
-
Dec 14th, 2001, 06:20 AM
#16
Thread Starter
Addicted Member
Yeah, my ADODB connections work fine.
Am I right in thinking a problem in the dll itself would create an error further on in the code and a different message? If so, it must be something to do with the DLL reg.
Hmm...
-
Dec 14th, 2001, 06:41 AM
#17
post your code or upload it as an attachment for me please
-
Dec 14th, 2001, 07:18 AM
#18
Thread Starter
Addicted Member
Here's my code. There's not much, so if there is a problem, it should be easy to spot.
And thanks for your time.
-
Dec 14th, 2001, 07:43 AM
#19
-
Dec 14th, 2001, 07:45 AM
#20
and here's the working copy ...
(run the HTML page first)
-
Dec 14th, 2001, 07:46 AM
#21
Black Cat
Originally posted by sweevo
I'm guessing I'm doing something wrong with the registration. Do I have to do it on the actual server, or can I do it locally as I've been trying?
The COM object (your dll) has to be registered in the Registry of the web server, not in the registry of your local machine. What happens is when the web server's ASP engine hits the Server.CreateObject("Something.Class"), it looks in the registry for the "Something.Class" to know where to find the *.dll file to use for that.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Dec 14th, 2001, 07:57 AM
#22
PowerPoster
hi
Worked just the way it shd at my end.
Just changed the createobject to server.createobject
-
Dec 14th, 2001, 08:51 AM
#23
Thread Starter
Addicted Member
Thanks everyone. Just got back to my computer to find all the responses
I'm going to find my server and do some stuff on there, so hopefully it'll work.
Thanks again, I appreciate the help. And no doubt you'll be hearing from me again at some point in the not-so-distant future
-
Dec 17th, 2001, 07:02 AM
#24
Thread Starter
Addicted Member
And you thought you were rid of me!
Got the dll registered and stuff, no errors, but can't get the modified variable to output in the ASP page. Do I need to do REQUEST of some sort?
Alex, I think this was what you were trying to tell me above (with the link to the other thread) but I can't find the answer
Thanks
-
Dec 17th, 2001, 07:35 AM
#25
Hehe - this took well over 2 weeks till I grasped it ! 
I'll try & explain it in a few paragraphs here .
I have a web site - www.wig.com With a default starting page of the same name wig.html. What happens when you (a user) type in www.wig.com on your browser is it sends a request upto my server stating you want to see this default page.
Rather than my server displaying this page, what it does is make a copy of the requested file (wig.html). When you tried to access the page / requested this by typing in the website into your browser, my server takes your IP address and sends this copy of the wig.html page down to your computer where it stays in your "Temporary Internet Files" folder. This means it saves my server processing and will load the page up quicker as you're accessing it from your PC rather than over the internet. This page is totally disowned now by the server and is in no way linked to it any more now.
This is where ASP comes in. In the copied page, you'll normally have a line like this :
<FORM Name="frm1" Method="post" Action="MyPage.asp"> This is an address to the server the page first came from, and the name of the page which it needs to be sent to. I.e. if I have a newsletter option for my users, the above wig.html page might have a textbox on it where my users can enter an e-mail address and sign up to the newsletter. When this is filled and the page is submitted, the wig.html page takes the information in the above line, and sends a copy of itself upto the named page on my server (kinda like the reverse of when you typed in www.wig.com into your browser, you send my server the page). This "MyPage.asp" page is listening out for requests and will pick up your page coming in whereby it will then grab the e-mail address and add it to the list of those who want to recieve the newsletter. This is basically how the request and response pages work. Your page being sent to the server is REQUESTING the asp page to process the e-mail address.
I think where you might be going wrong is mistaking this part - I'm guessing you might just be using an asp page on it's own, rather than using 2 pages together. The ASP page is for processing, you normally have a front end html page for the viewing part (which the user sees) as on my example.
I think if you must use the asp page on it's own, then you use document.write from the top of my head, but html and asp pages notmally work in pairs !
-
Dec 17th, 2001, 07:38 AM
#26
I realise that might have confused the hell out of you, and I'm prepared for a load of questions about the above 
Also, post your project again if you can't get your head round the above.
-
Dec 17th, 2001, 08:02 AM
#27
Thread Starter
Addicted Member
Thanks. This is the situation...
I have written/am writing a project which has an initial input HTML form, with some input fields. When submitted, the form data is passed to an asp page that obtains variables from the inputs and creates an sql query from them. ADODB connections are then created for the DBs and the results are created (all in the one asp page).
That's the bit I have done and understand.
However, I am now trying to add to this another database that is custom built and does not support ADO or SQL or anything, so I've basically got to call a dll that performs API calls to this database's own dlls (I'll worry about that later )
However, I've never written or used dlls in this way, so am first trying to make a very simple one that simply receives a variable from the asp, changes it and returns it to the asp so this can then output it. I want to keep this to one asp page if possible because the other databases are accessed, processed and output from there.
Thanks again
-
Dec 17th, 2001, 08:07 AM
#28
Thread Starter
Addicted Member
Here's what I'm playing with at the moment...
-
Dec 17th, 2001, 09:47 AM
#29
I think this is the kinda thing you're after ?
Last edited by alex_read; Dec 18th, 2001 at 04:25 AM.
-
Dec 18th, 2001, 04:25 AM
#30
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|