SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old November 23rd, 2004, 12:33 AM
Graham Reeds Graham Reeds is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 28 Graham Reeds User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 24 sec
Reputation Power: 0
Passing Variables betwen DLLs

Final problem:

I have two DLL's. One is controls Business logic and is called Enterprise_BUS and the other is called Enterprise_DAL. The _BUS would normally contain business logic but for the time being it simply passes the variables from to the _DAL.

So I have this:
PHP Code:
Declare Function FindByName Lib "Enterprise_DAL.dll" (EmployeeName As String) As ADODB.Recordset

... other declares ...
 
'
 Find By Employee
Public Function FindByName(EmployeeName As String) As ADODB.Recordset
    Dim RS As ADODB.Recordset
    Set RS = FindByName(EmployeeName)
    Set FindByName = RS
End Function

... rest of code similar to example 


However I get a Ambiguous name detected error when compiling.

If I change the name of the functions I will violate the task conditions.

So my question is two-fold: Is the way I've declared it correct (I've been using the terse examples from the MSDN as a template) and how do I make the Ambiguous name error disappear?

I have a feeling the answer might solve both problems at once.

Thanks again, Graham Reeds

Reply With Quote
  #2  
Old November 23rd, 2004, 01:28 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
Quote:
... how do I make the Ambiguous name error disappear?

I have a feeling the answer might solve both problems at once.

Thanks again, Graham Reeds

This part is pretty easy. In your code you have used the same name for more than one variable, object, or procedure.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old November 23rd, 2004, 05:49 AM
Graham Reeds Graham Reeds is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 28 Graham Reeds User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 24 sec
Reputation Power: 0
But the procedures are in different DLL's, and the spec says they have to stay the same.

Are you sure there is no other way around it?

Reply With Quote
  #4  
Old November 23rd, 2004, 06:57 AM
Graham Reeds Graham Reeds is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 28 Graham Reeds User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 24 sec
Reputation Power: 0
I have got slightly further. I modified the declarations like so:

Code:
 
Private Declare Function FindByName_DAL Lib "Enterprise_DAL.dll" Alias "FindByName" (EmployeeName As String) As ADODB.Recordset


and the function like this:

Code:
 
' Find By Employee
Public Function FindByName(EmployeeName As String) As ADODB.Recordset
	Dim RS As ADODB.Recordset
	Set RS = FindByName_DAL(EmployeeName)
	Set FindByName = RS
End Function

But when I run the program I get the error "Can't find DLL entry point FindByName in Enterprise_DAL.dll" However, if I change the line in the ASP to use the Enterprise_DAL class instead of Enterprise_BUS it works fine. I seem to solve one error to slam straight into another.

Reply With Quote
  #5  
Old November 23rd, 2004, 04:32 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
You can't just arbitrarily rename a function declaration from a dll, it must match the dll.

You should rename your vb code FindByName function to something else to eliminate the duplication of the function name.

Reply With Quote
  #6  
Old November 23rd, 2004, 07:47 PM
Graham Reeds Graham Reeds is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 28 Graham Reeds User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 24 sec
Reputation Power: 0
The way I understand it, in the declaration the Alias allows VB to call functions that they wouldn't normally be able to call i.e: functions that begin with an underscore. In C++ terms it would be like having a pointer to a function.

So what my declaration does (or how I planned it to work) would be to say "There's a function in Enterprise_DAL.dll which is called FindByName. To differentiate it from the FindByName in this DLL we will call it FindByName_DAL".

Take this example from the MSDN (http://msdn.microsoft.com/library/d...llprocedure.asp):

Declare Function InvertRect Lib "user32" Alias "InvertRectA" (ByVal hdc As Long, lpRect As RECT) As Long

The actual windows function is InvertRectA but the programmer just types MyLong = InvertRect(MyHDC, myRect).

The errormessage suggests that my assumption of how it works is correct: "Can't find DLL entry point FindByName in Enterprise_DAL.dll". It's looking for the FindByName function. Just that it can't find it.

I also tried removing the .DLL extension from the declaration and copying the DLL's to the same directory as the asp (they were previously in separate directories) and that failed to work also.

Thanks, Graham Reeds.

P.S.: I would of replied sooner, but I installed SP6 for VB thinking it might help, but it killed IIS stone dead, and spent the last few hours fixing that, and then the permissions in SQL Server 2000.

Reply With Quote
  #7  
Old November 23rd, 2004, 09:01 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 18 h 33 m 48 sec
Reputation Power: 180
Why don't you just leave the dll function name alone, and rename your VB code function?

Reply With Quote
  #8  
Old November 23rd, 2004, 09:58 PM
Graham Reeds Graham Reeds is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 28 Graham Reeds User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 24 sec
Reputation Power: 0
Quote:
Originally Posted by Doug G
Why don't you just leave the dll function name alone, and rename your VB code function?

According to the specs I was asked to follow I am not allowed. The functions in the _BUS are just to pass the variables along to the corresponding functions in the _DAL dll.

I've handed it in incomplete - I had overrun the time allowed anyway. But then again two weeks ago I had never touched IIS, SQL Server 2000, VB or ASP (I'm a C++ & Oracle man myself) so I think I have done okay.

I do appreciate your help though.

Thanks

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Passing Variables betwen DLLs


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway