Solved

Calling a form within a DLL

Posted on 2003-12-03
6
596 Views
Last Modified: 2010-05-01
This is a follow up of question:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20814217.html

I need to get vector information from a database, transform it into an image, save the image to a file (with a random filename), pass some database information as well as the filename of the image file to a web page for display. (I will have another routine clean up the files so that there isn't a disk space problem)

I currently have two VB projects that do the following:
1) A DLL that will return the needed data from a database. (I can call this DLL from a web page and display the data)
2) A project that has form that can transform the data into an image and save it to a file. (If I hard code the data I can run the project and create an image file)

I need to know:
A) How to pass the database information to the form (the data needed is a char(20) and an variable size array of char(60))
B) How to pass the filename of the created file back to the DLL and then back to the web page that will display the image

I'm not sure if I need to create an Executable from the project (number 2) and run it from the DLL. Or if I need to include the form in the DLL and call it internally.

Urgent help is needed. (I will only be in the office till 11:00 am EST and not back until Monday 12/8 and I'd like to have this working before I leave)
0
Comment
Question by:resedlar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9866973
A. just pass as recordset
B. You are not passed as file name, open the file and read the content as pass the content as string
On the other end, just load the string to picturebox
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 500 total points
ID: 9867274
In the dll that contains the form, you still need a class which should contain an instance of that form.  E.g.,


Option Explicit

Private m_frmPicture As NameOfFormInMyDLL



Public Function TransferToFile(ByVal DatabaseData As Variant) As String

    'manipulate data to create picture and save to file

    'return file name
    TransferToFile = strFileNameCreated

End Sub



Private Sub Class_Initialize()
    Set m_frmPicture = New NameOfFormInMyDLL
    Load m_frmPicture
End Sub

Private Sub Class_Terminate()
    Unload m_frmPicture
    Set m_frmPicture = Nothing
End Sub




Then, from your asp page:


<%
Dim objDrawPicture, strFile

Set objDrawPicture = Server.CreateObject("MyDLL.DrawPicture")
strFile = objDrawPicture.TransferToFile(vMyDBData)
%>

<img src="<%=strFile%>">
0
 

Author Comment

by:resedlar
ID: 9867513
Thanks AzraSound,

I have made the changes to the DLL that you listed. Recreated the DLL and reinstalled it in COM+ I am now getting an error in my ASP page that reads:

Server object, ASP 0177 (0x80010007)
The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call may have executed.
/RealEstate/sketch.asp, line 49

Line 49 is the "set objDrawpicture=Server.CreateObject("MyDLL.DrawPicture") line.

I need to go to training for the rest of the week so, I'll not be able to debug again till Monday.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:resedlar
ID: 9867558
OK,

Now that I have actually closed Component services, I am getting an error on the "strFile = objDrawPicture.TransferToFile(vMyDBData)" line:

Automation error

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 9867585
Hard to say without some debugging.  I assume vMyDBData is a variable actually containing the data you have pulled from your database?
0
 

Author Comment

by:resedlar
ID: 9897147
Typos, Typos, Typos. Now that I have fixed them everything is working great.

Thanks Azra

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question