Solved

Through Automation Object COM function, accessing SQL Server Database

Posted on 2004-04-20
3
888 Views
Last Modified: 2007-12-19
I created Automation Object (COM) using Delphi. I created a function in that COM which will gather some data from some text files and insert them into MS-SQL table. Every time I call that function it should connect to the database to post new data.

I succeeded in gathering my data from text file throu' the method from COM object but I failed to connect to the database. I tried to use  ODBC(with BDE components, with ADO Components)

In more details:

COM Automation Object has function which has following input parameters as strings & get output string parameter. It sends ODBC DataSource( to access MS SQL Server), Table Name, UserID & Pwd parameters to update database.

    function ImpExec(const pDataSource, pTable, pUser ID, pPwd: WideString): WideString; safecall;

From Delphi exe Application, when I try to call this method providing input parameters by using the above Object, it give the following error

    'Project raised exception class EOleException with message 'Catastrophic failure'

What could be the error, I couldn't access database by using this method from that COM Object.

Also how to debug the Com Object from exe application.

Expecting a solution soon.
0
Comment
Question by:HamidHossain
[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
  • 2
3 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10866897

   1) Let's debug it :
         - build the COM with debug into and register it
         - while opened in delphi go to Run / Parameters and for host application put C:\WINNT\System32\dllhost.exe
         - put a break point in the beggining of the method and run it.

   2) Open another Delphi and open the client. Run it and call the server method. The first Delphi should stop on the first line of the COM object
0
 

Author Comment

by:HamidHossain
ID: 10867870
I built COM by using Automation Object in ActiveX Library.

You stated that  'build the COM with debug into and register it'.  what it means 'debug into', is it a option we have to give in COM or where?

As you told I set Run / Parameters for host application as  C:\WINNT\System32\dllhost.exe. Then I put a break point in the beginning of the method & run that COM it tells ' Could not find program C:\WINNT\System32\dllhost.exe'

Then I opened another Delphi client application & run it by calling that server method. It is not going  & stopping on the first line of COM method in Server Project. Still it stops only  at client.

Following is the coding in Client.

( CP1 : IComImpACSObj; -- Server Interface Object

CP1 := CoComImpACSObj.Create as IComImpACSObj; -- Creating COM Object instance

CP1.ImpExec('ACS_DS', 'trans', 'sa', ''); - it stop here & tells 'Project raised exception class EOleException with message 'Catastrophic failure' )
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 500 total points
ID: 10877277

  Yes, I see - in fact you didn't debugged the server

  Register the ActiveX - Run / Register ActiveX Server.
  if you are on XP - C:\WINDOWS\system32\dllhost.exe.

  TRY THIS : You can also put as host application the client that use this ActiveX - Your Client Application. Then you need only one Delphi instance.

   If you do it correctly - it should stop.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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