Board index » delphi » Accessing SQL Server via activex written in Delphi

Accessing SQL Server via activex written in Delphi

I wonder if anyone can help me a little here...

I want to write non visual activex object that manipulates sql server.
All I want to do is to post a single record to an sql server table.
Nothing complicated.  In fact I want to be able to pass parameters to
an SQL Server stored procedure.  

Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5 and all
the knobs and SP's.

Why an activex oblect - because I want to be able to use this object
from delphi, MS Office and/or the internet/intranet using active
server pages.  

If it is not possible then Delphi is surely doomed as a development
environment and this would be a shame since the thought of having to
work with VB does not appeal one little bit.

Hope springs eternal

 

Re:Accessing SQL Server via activex written in Delphi


Hi,

If by 'non-visual activex object' you mean a COM server, then this is
definitely possible, as I have been doing it for some time here. I'm not
using Delphi's C/S stuff, but the implementation details should be
similar for that.

I use a third party ODBC component, and I create the connection and
query components in the initialize procedure of my COM Server. I destroy
the objects in the destroy destructor of same. If you want to implement
apartment threading, make sure the DB components you rely on are thread
safe. The ones I use are not, and so I have to implement everything as
'ciSingleInstance'.

I hope this helps to reassure you that what you are trying to do is
possible (if I understand you correctly).

Good luck,

Steve

Quote
Terry wrote:
> I wonder if anyone can help me a little here...

> I want to write non visual activex object that manipulates sql server.

> All I want to do is to post a single record to an sql server table.
> Nothing complicated.  In fact I want to be able to pass parameters to
> an SQL Server stored procedure.

> Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5 and all

> the knobs and SP's.

> Why an activex oblect - because I want to be able to use this object
> from delphi, MS Office and/or the internet/intranet using active
> server pages.

> If it is not possible then Delphi is surely doomed as a development
> environment and this would be a shame since the thought of having to
> work with VB does not appeal one little bit.

> Hope springs eternal

Re:Accessing SQL Server via activex written in Delphi


Terry,

I would add one other note to the other reply you received. If you are
trying to create something that can be used in MS Office, Delphi, and the
INTERNET, you are in for a surprise in ANY development environment.
Specifically, how would SQL Server be able to talk from John Doe's computer
to your SQL Server database using nothing but MSSQL? I don't think MSSQL
supports that type of setup. However, if you are using IIS to login
indirectly to the SQL Server to get the data then you should be OK.

In summary, if you can do it in VB, you can do it with Delphi too.
--
Dan Miser
www.execpc.com/~dmiser

Quote
Terry wrote in message <[email protected]>...
>I wonder if anyone can help me a little here...

>I want to write non visual activex object that manipulates sql server.
>All I want to do is to post a single record to an sql server table.
>Nothing complicated.  In fact I want to be able to pass parameters to
>an SQL Server stored procedure.

>Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5 and all
>the knobs and SP's.

>Why an activex oblect - because I want to be able to use this object
>from delphi, MS Office and/or the internet/intranet using active
>server pages.

>If it is not possible then Delphi is surely doomed as a development
>environment and this would be a shame since the thought of having to
>work with VB does not appeal one little bit.

>Hope springs eternal

Re:Accessing SQL Server via activex written in Delphi


Terry,
You can write ax server which communicates with mssql via sql-dmo if you
dont want bde involved, or otherwise. In either case, your client
(application or a web page) would use interfaces from your ax server to do
whatever it needs.

Igor.

Quote
Dan Miser wrote in message <[email protected]>...
>Terry,

>I would add one other note to the other reply you received. If you are
>trying to create something that can be used in MS Office, Delphi, and the
>INTERNET, you are in for a surprise in ANY development environment.
>Specifically, how would SQL Server be able to talk from John Doe's computer
>to your SQL Server database using nothing but MSSQL? I don't think MSSQL
>supports that type of setup. However, if you are using IIS to login
>indirectly to the SQL Server to get the data then you should be OK.

>In summary, if you can do it in VB, you can do it with Delphi too.
>--
>Dan Miser
>www.execpc.com/~dmiser

>Terry wrote in message <[email protected]>...
>>I wonder if anyone can help me a little here...

>>I want to write non visual activex object that manipulates sql server.
>>All I want to do is to post a single record to an sql server table.
>>Nothing complicated.  In fact I want to be able to pass parameters to
>>an SQL Server stored procedure.

>>Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5 and all
>>the knobs and SP's.

>>Why an activex oblect - because I want to be able to use this object
>>from delphi, MS Office and/or the internet/intranet using active
>>server pages.

>>If it is not possible then Delphi is surely doomed as a development
>>environment and this would be a shame since the thought of having to
>>work with VB does not appeal one little bit.

>>Hope springs eternal

Re:Accessing SQL Server via activex written in Delphi


Quote
In article <[email protected]>, {*word*104}Plus wrote:
> You can write ax server which communicates with mssql via sql-dmo if you
> dont want bde involved,

How do you propose to communicate between the ActiveX server and the
ActiveX client?
-
Dan Miser
http://www.execpc.com/~dmiser

Re:Accessing SQL Server via activex written in Delphi


Dan,

"Communicate" meaning what exactly?

If all he needs to do is to

Quote
>>post a single record to an sql server table.
>>Nothing complicated.  In fact I want to be able to pass parameters to
>>an SQL Server stored procedure.

what is the point of going through bde if you can create a class in ax
server methods of which will take some parameters and allow save data to
table(s) or run stored procs via dmo? If he needs browsing capabilities,
that's another story. While still can be done via dmo, a lot more work
involved in setting up client side to be data-aware. As for actual
manipulation, if server implements dispatch, i would think you can
manipulate it from the script (asp or other kind).

Unless I misunderstood the question.

Igor.

Quote
Dan Miser wrote in message ...
>In article <[email protected]>, {*word*104}Plus wrote:
>> You can write ax server which communicates with mssql via sql-dmo if you
>> dont want bde involved,

>How do you propose to communicate between the ActiveX server and the
>ActiveX client?
>-
>Dan Miser
>http://www.execpc.com/~dmiser

Re:Accessing SQL Server via activex written in Delphi


The problem is how do you use sql-dmo (or BDE) in an ActiveX control over
the Internet? When you write an ActiveX control, that control gets
downloaded to the client machine. It is not on the server. At that point, it
would be trying to connect my PC (connected through my ISP) to your database
on your network. Unless sql-dmo provides a way to do that natively, you will
need to control every aspect of the communication between the client and the
server. For example, the sql statement, the return result, any datasets,
error checking, etc.
--
Dan Miser
www.execpc.com/~dmiser

Quote
{*word*104}Plus wrote in message <[email protected]>...
>Dan,

>"Communicate" meaning what exactly?

>If all he needs to do is to

>>>post a single record to an sql server table.
>>>Nothing complicated.  In fact I want to be able to pass parameters to
>>>an SQL Server stored procedure.

>what is the point of going through bde if you can create a class in ax
>server methods of which will take some parameters and allow save data to
>table(s) or run stored procs via dmo? If he needs browsing capabilities,
>that's another story. While still can be done via dmo, a lot more work
>involved in setting up client side to be data-aware. As for actual
>manipulation, if server implements dispatch, i would think you can
>manipulate it from the script (asp or other kind).

>Unless I misunderstood the question.

>Igor.

>Dan Miser wrote in message ...
>>In article <[email protected]>, {*word*104}Plus wrote:
>>> You can write ax server which communicates with mssql via sql-dmo if you
>>> dont want bde involved,

>>How do you propose to communicate between the ActiveX server and the
>>ActiveX client?
>>-
>>Dan Miser
>>http://www.execpc.com/~dmiser

Re:Accessing SQL Server via activex written in Delphi


If he's going to be using Active Server Pages (I think he mentioned this
in the original question), then there doesn't have to be an activeX
control on the client side.

ASP can just instantiate a dataobject in his server to get at the SQL
code and pass back the data to the front-end as html. I'm guessing
(though I have little experience with this) that he could have the same
server support activex controls on Delphi forms if it's necessary to
support windows form based programs also.

The one bad thing I've heard about SQL-DMO is that it's an STA, and so
if you write an STA yourself, you will get only synchronous execution of
queries (since there will be only one execution thread for all of the
threads inside your STA). I have not verified this at all, but people
who use the product have said this to me. (STA's are probably useless
for ASP anyway, for the same reason, since ASP has lots of worker
threads calling into your server.)

Any comments and corrections greatly appreciated,

Steve Midgley

Quote
Dan Miser wrote:
> The problem is how do you use sql-dmo (or BDE) in an ActiveX control
> over
> the Internet? When you write an ActiveX control, that control gets
> downloaded to the client machine. It is not on the server. At that
> point, it
> would be trying to connect my PC (connected through my ISP) to your
> database
> on your network. Unless sql-dmo provides a way to do that natively,
> you will
> need to control every aspect of the communication between the client
> and the
> server. For example, the sql statement, the return result, any
> datasets,
> error checking, etc.
> --
> Dan Miser
> www.execpc.com/~dmiser

> {*word*104}Plus wrote in message <[email protected]>...
> >Dan,

> >"Communicate" meaning what exactly?

> >If all he needs to do is to

> >>>post a single record to an sql server table.
> >>>Nothing complicated.  In fact I want to be able to pass parameters
> to
> >>>an SQL Server stored procedure.

> >what is the point of going through bde if you can create a class in
> ax
> >server methods of which will take some parameters and allow save data
> to
> >table(s) or run stored procs via dmo? If he needs browsing
> capabilities,
> >that's another story. While still can be done via dmo, a lot more
> work
> >involved in setting up client side to be data-aware. As for actual
> >manipulation, if server implements dispatch, i would think you can
> >manipulate it from the script (asp or other kind).

> >Unless I misunderstood the question.

> >Igor.

> >Dan Miser wrote in message ...
> >>In article <[email protected]>, {*word*104}Plus wrote:
> >>> You can write ax server which communicates with mssql via sql-dmo
> if you
> >>> dont want bde involved,

> >>How do you propose to communicate between the ActiveX server and the

> >>ActiveX client?
> >>-
> >>Dan Miser
> >>http://www.execpc.com/~dmiser

Re:Accessing SQL Server via activex written in Delphi


I'm in total agreement if the intended use is strictly for server-side
processing via ASP.
--
Dan Miser
www.execpc.com/~dmiser

Quote
>If he's going to be using Active Server Pages (I think he mentioned this
>in the original question), then there doesn't have to be an activeX
>control on the client side.

<snip>

Re:Accessing SQL Server via activex written in Delphi


Hm, haven't thought of that... Good point.

Quote
Dan Miser wrote in message <[email protected]>...
>The problem is how do you use sql-dmo (or BDE) in an ActiveX control over
>the Internet? When you write an ActiveX control, that control gets
>downloaded to the client machine. It is not on the server. At that point,
it
>would be trying to connect my PC (connected through my ISP) to your
database
>on your network. Unless sql-dmo provides a way to do that natively, you
will
>need to control every aspect of the communication between the client and
the
>server. For example, the sql statement, the return result, any datasets,
>error checking, etc.
>--
>Dan Miser
>www.execpc.com/~dmiser

>{*word*104}Plus wrote in message <[email protected]>...
>>Dan,

>>"Communicate" meaning what exactly?

>>If all he needs to do is to

>>>>post a single record to an sql server table.
>>>>Nothing complicated.  In fact I want to be able to pass parameters to
>>>>an SQL Server stored procedure.

>>what is the point of going through bde if you can create a class in ax
>>server methods of which will take some parameters and allow save data to
>>table(s) or run stored procs via dmo? If he needs browsing capabilities,
>>that's another story. While still can be done via dmo, a lot more work
>>involved in setting up client side to be data-aware. As for actual
>>manipulation, if server implements dispatch, i would think you can
>>manipulate it from the script (asp or other kind).

>>Unless I misunderstood the question.

>>Igor.

>>Dan Miser wrote in message ...
>>>In article <[email protected]>, {*word*104}Plus wrote:
>>>> You can write ax server which communicates with mssql via sql-dmo if
you
>>>> dont want bde involved,

>>>How do you propose to communicate between the ActiveX server and the
>>>ActiveX client?
>>>-
>>>Dan Miser
>>>http://www.execpc.com/~dmiser

Re:Accessing SQL Server via activex written in Delphi


Steve,

Can you provide any samples of what you've done.  I'm trying to replace an
ASP script which I have been using to populate a Crystal Report based on an
Interbase back-end.

The Interbase ODBC driver isn't thread-safe, so I figure I'll need to
re-write my ASP script as a Delphi CGI.

TIA,

David Montgomery
[email protected]*no*spam*directfile.com

Quote
Steve Midgley wrote in message <[email protected]_anti.spam.com>...
>Hi,

>If by 'non-visual activex object' you mean a COM server, then this is
>definitely possible, as I have been doing it for some time here. I'm not
>using Delphi's C/S stuff, but the implementation details should be
>similar for that.

>I use a third party ODBC component, and I create the connection and
>query components in the initialize procedure of my COM Server. I destroy
>the objects in the destroy destructor of same. If you want to implement
>apartment threading, make sure the DB components you rely on are thread
>safe. The ones I use are not, and so I have to implement everything as
>'ciSingleInstance'.

>I hope this helps to reassure you that what you are trying to do is
>possible (if I understand you correctly).

>Good luck,

>Steve

>Terry wrote:

>> I wonder if anyone can help me a little here...

>> I want to write non visual activex object that manipulates sql server.

>> All I want to do is to post a single record to an sql server table.
>> Nothing complicated.  In fact I want to be able to pass parameters to
>> an SQL Server stored procedure.

>> Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5 and all

>> the knobs and SP's.

>> Why an activex oblect - because I want to be able to use this object
>> from delphi, MS Office and/or the internet/intranet using active
>> server pages.

>> If it is not possible then Delphi is surely doomed as a development
>> environment and this would be a shame since the thought of having to
>> work with VB does not appeal one little bit.

>> Hope springs eternal

Re:Accessing SQL Server via activex written in Delphi


Hi,

You should be able to integrate Delphi with your Interbase ODBC driver
and ASP. It's almost exactly what I'm doing. I heartily recommend

WWW->ASP->Delphi COM->ODBC->database server

over

WWW->CGI->Delphi->ODBC->database server

ASP provides (as you know) a handy environment for writing your simple
HTML formatting stuff. Writing this in CGI, for me, is like pulling your
own teeth without anesthetic!

Instead, for complex data stuff (where ASP lags because it's so slow),
use a Delphi COM backend that is instantiated by ASP (with
server.createobject).  This COM server can safely connect to the SQL
backend through whatever ODBC technology you want to use (or through
ADO, DAO, RDO or any other way). If Delphi can do it, Delphi COM can do
it too.

Since your ODBC driver is not thread safe, you can't even consider
writing a multi-threaded application, and if it's as bad off as mine, it
won't even support multiple connections to the backend at once (in the
same process space).

This means, if your stuff is dumb like mine, you should write your
Delphi COM server with a 'ciSingleInstance' instantiation model. This
will cost you some ram and general slow down, but it's better than not
working, right? :)

For ASP, this is actually better than a single-threaded apartment (STA),
because you actually get the appearance of a multi-threaded apartment
(MTA) (multiple ASP worker threads can make calls into your COM objects
simultaneously).

The other info that will help is that you should instantiate your ODBC
drivers manually in the .Initialize procedure of your COM server, and
you should destroy them in the .destroy destructor (make sure to call
the inherited method too!). Don't drop them onto the main form if you
can possibly avoid it. It will likely give you architecture problems
down the road when you decide to ditch your current ODBC drivers for
thread-safe ones.

If you still want a very simple, Delphi COM-ASP sample, let me know and
I'll cook one up. I don't think my actual database code won't be of much
interest to you since it's highly customized--er, generic :)

Good luck, and let me know if I can help,

Steve Midgley

Quote
David Montgomery wrote:
> Steve,

> Can you provide any samples of what you've done.  I'm trying to
> replace an
> ASP script which I have been using to populate a Crystal Report based
> on an
> Interbase back-end.

> The Interbase ODBC driver isn't thread-safe, so I figure I'll need to
> re-write my ASP script as a Delphi CGI.

> TIA,

> David Montgomery
> [email protected]*no*spam*directfile.com

> Steve Midgley wrote in message
> <[email protected]_anti.spam.com>...
> >Hi,

> >If by 'non-visual activex object' you mean a COM server, then this is

> >definitely possible, as I have been doing it for some time here. I'm
> not
> >using Delphi's C/S stuff, but the implementation details should be
> >similar for that.

> >I use a third party ODBC component, and I create the connection and
> >query components in the initialize procedure of my COM Server. I
> destroy
> >the objects in the destroy destructor of same. If you want to
> implement
> >apartment threading, make sure the DB components you rely on are
> thread
> >safe. The ones I use are not, and so I have to implement everything
> as
> >'ciSingleInstance'.

> >I hope this helps to reassure you that what you are trying to do is
> >possible (if I understand you correctly).

> >Good luck,

> >Steve

> >Terry wrote:

> >> I wonder if anyone can help me a little here...

> >> I want to write non visual activex object that manipulates sql
> server.

> >> All I want to do is to post a single record to an sql server table.

> >> Nothing complicated.  In fact I want to be able to pass parameters
> to
> >> an SQL Server stored procedure.

> >> Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5 and
> all

> >> the knobs and SP's.

> >> Why an activex oblect - because I want to be able to use this
> object
> >> from delphi, MS Office and/or the internet/intranet using active
> >> server pages.

> >> If it is not possible then Delphi is surely doomed as a development

> >> environment and this would be a shame since the thought of having
> to
> >> work with VB does not appeal one little bit.

> >> Hope springs eternal

Re:Accessing SQL Server via activex written in Delphi


Steve,

Thanks for the great answer!  What makes usenet such a great resource is
that I would have *never* thought to create my own COM server to do this.  I
was thinking in a very linear fashion, and you gave me something new to
try...

I'll let you know how it works.

Best Regards,

David Montgomery
[email protected]*nospamplease*directfile.com

PS - If you have your own example, and it's _convenient_ for you, please
send it along if you don't mind.  Don't bother if you have to write a
specific example.

Quote
Steve Midgley wrote in message <[email protected]_anti.spam.com>...
>Hi,

>You should be able to integrate Delphi with your Interbase ODBC driver
>and ASP. It's almost exactly what I'm doing. I heartily recommend

>WWW->ASP->Delphi COM->ODBC->database server

>over

>WWW->CGI->Delphi->ODBC->database server

>ASP provides (as you know) a handy environment for writing your simple
>HTML formatting stuff. Writing this in CGI, for me, is like pulling your
>own teeth without anesthetic!

>Instead, for complex data stuff (where ASP lags because it's so slow),
>use a Delphi COM backend that is instantiated by ASP (with
>server.createobject).  This COM server can safely connect to the SQL
>backend through whatever ODBC technology you want to use (or through
>ADO, DAO, RDO or any other way). If Delphi can do it, Delphi COM can do
>it too.

>Since your ODBC driver is not thread safe, you can't even consider
>writing a multi-threaded application, and if it's as bad off as mine, it
>won't even support multiple connections to the backend at once (in the
>same process space).

>This means, if your stuff is dumb like mine, you should write your
>Delphi COM server with a 'ciSingleInstance' instantiation model. This
>will cost you some ram and general slow down, but it's better than not
>working, right? :)

>For ASP, this is actually better than a single-threaded apartment (STA),
>because you actually get the appearance of a multi-threaded apartment
>(MTA) (multiple ASP worker threads can make calls into your COM objects
>simultaneously).

>The other info that will help is that you should instantiate your ODBC
>drivers manually in the .Initialize procedure of your COM server, and
>you should destroy them in the .destroy destructor (make sure to call
>the inherited method too!). Don't drop them onto the main form if you
>can possibly avoid it. It will likely give you architecture problems
>down the road when you decide to ditch your current ODBC drivers for
>thread-safe ones.

>If you still want a very simple, Delphi COM-ASP sample, let me know and
>I'll cook one up. I don't think my actual database code won't be of much
>interest to you since it's highly customized--er, generic :)

>Good luck, and let me know if I can help,

>Steve Midgley

>David Montgomery wrote:

>> Steve,

>> Can you provide any samples of what you've done.  I'm trying to
>> replace an
>> ASP script which I have been using to populate a Crystal Report based
>> on an
>> Interbase back-end.

>> The Interbase ODBC driver isn't thread-safe, so I figure I'll need to
>> re-write my ASP script as a Delphi CGI.

>> TIA,

>> David Montgomery
>> [email protected]*no*spam*directfile.com

>> Steve Midgley wrote in message
>> <[email protected]_anti.spam.com>...
>> >Hi,

>> >If by 'non-visual activex object' you mean a COM server, then this is

>> >definitely possible, as I have been doing it for some time here. I'm
>> not
>> >using Delphi's C/S stuff, but the implementation details should be
>> >similar for that.

>> >I use a third party ODBC component, and I create the connection and
>> >query components in the initialize procedure of my COM Server. I
>> destroy
>> >the objects in the destroy destructor of same. If you want to
>> implement
>> >apartment threading, make sure the DB components you rely on are
>> thread
>> >safe. The ones I use are not, and so I have to implement everything
>> as
>> >'ciSingleInstance'.

>> >I hope this helps to reassure you that what you are trying to do is
>> >possible (if I understand you correctly).

>> >Good luck,

>> >Steve

>> >Terry wrote:

>> >> I wonder if anyone can help me a little here...

>> >> I want to write non visual activex object that manipulates sql
>> server.

>> >> All I want to do is to post a single record to an sql server table.

>> >> Nothing complicated.  In fact I want to be able to pass parameters
>> to
>> >> an SQL Server stored procedure.

>> >> Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5 and
>> all

>> >> the knobs and SP's.

>> >> Why an activex oblect - because I want to be able to use this
>> object
>> >> from delphi, MS Office and/or the internet/intranet using active
>> >> server pages.

>> >> If it is not possible then Delphi is surely doomed as a development

>> >> environment and this would be a shame since the thought of having
>> to
>> >> work with VB does not appeal one little bit.

>> >> Hope springs eternal

Re:Accessing SQL Server via activex written in Delphi


Compliments will get you everywhere. Here's a link to a simple ASP
Delphi COM Server. There is a delphi project and two sample ASP files
included. It should compile out of the box. Let me know if it doesn't.
Make sure you read the instructions in the main pascal file on how to
configure ASP to run out of process components (this project is one).

I guess I can't post this zip binary directly to the newsgroup so you
can get it off of my private web site:

http://shell6.ba.best.com/~midgley/ASPComSample/ASPComSample.zip

Hopefully this will help you and others. There are a few advanced topics
in this project as well as the basics. I've tried to break out
everything so you can use only what you need. Good luck with this and
feel free to write me with any questions concerning this thing. I've
been meaning to write this example for quite some time, so I'm glad you
gave me the motivation to do it.

See you,

Steve

Quote
David Montgomery wrote:
> Steve,

> Thanks for the great answer!  What makes usenet such a great resource
> is
> that I would have *never* thought to create my own COM server to do
> this.  I
> was thinking in a very linear fashion, and you gave me something new
> to
> try...

> I'll let you know how it works.

> Best Regards,

> David Montgomery
> [email protected]*nospamplease*directfile.com

> PS - If you have your own example, and it's _convenient_ for you,
> please
> send it along if you don't mind.  Don't bother if you have to write a
> specific example.

> Steve Midgley wrote in message
> <[email protected]_anti.spam.com>...
> >Hi,

> >You should be able to integrate Delphi with your Interbase ODBC
> driver
> >and ASP. It's almost exactly what I'm doing. I heartily recommend

> >WWW->ASP->Delphi COM->ODBC->database server

> >over

> >WWW->CGI->Delphi->ODBC->database server

> >ASP provides (as you know) a handy environment for writing your
> simple
> >HTML formatting stuff. Writing this in CGI, for me, is like pulling
> your
> >own teeth without anesthetic!

> >Instead, for complex data stuff (where ASP lags because it's so
> slow),
> >use a Delphi COM backend that is instantiated by ASP (with
> >server.createobject).  This COM server can safely connect to the SQL
> >backend through whatever ODBC technology you want to use (or through
> >ADO, DAO, RDO or any other way). If Delphi can do it, Delphi COM can
> do
> >it too.

> >Since your ODBC driver is not thread safe, you can't even consider
> >writing a multi-threaded application, and if it's as bad off as mine,
> it
> >won't even support multiple connections to the backend at once (in
> the
> >same process space).

> >This means, if your stuff is dumb like mine, you should write your
> >Delphi COM server with a 'ciSingleInstance' instantiation model. This

> >will cost you some ram and general slow down, but it's better than
> not
> >working, right? :)

> >For ASP, this is actually better than a single-threaded apartment
> (STA),
> >because you actually get the appearance of a multi-threaded apartment

> >(MTA) (multiple ASP worker threads can make calls into your COM
> objects
> >simultaneously).

> >The other info that will help is that you should instantiate your
> ODBC
> >drivers manually in the .Initialize procedure of your COM server, and

> >you should destroy them in the .destroy destructor (make sure to call

> >the inherited method too!). Don't drop them onto the main form if you

> >can possibly avoid it. It will likely give you architecture problems
> >down the road when you decide to ditch your current ODBC drivers for
> >thread-safe ones.

> >If you still want a very simple, Delphi COM-ASP sample, let me know
> and
> >I'll cook one up. I don't think my actual database code won't be of
> much
> >interest to you since it's highly customized--er, generic :)

> >Good luck, and let me know if I can help,

> >Steve Midgley

> >David Montgomery wrote:

> >> Steve,

> >> Can you provide any samples of what you've done.  I'm trying to
> >> replace an
> >> ASP script which I have been using to populate a Crystal Report
> based
> >> on an
> >> Interbase back-end.

> >> The Interbase ODBC driver isn't thread-safe, so I figure I'll need
> to
> >> re-write my ASP script as a Delphi CGI.

> >> TIA,

> >> David Montgomery
> >> [email protected]*no*spam*directfile.com

> >> Steve Midgley wrote in message
> >> <[email protected]_anti.spam.com>...
> >> >Hi,

> >> >If by 'non-visual activex object' you mean a COM server, then this
> is

> >> >definitely possible, as I have been doing it for some time here.
> I'm
> >> not
> >> >using Delphi's C/S stuff, but the implementation details should be

> >> >similar for that.

> >> >I use a third party ODBC component, and I create the connection
> and
> >> >query components in the initialize procedure of my COM Server. I
> >> destroy
> >> >the objects in the destroy destructor of same. If you want to
> >> implement
> >> >apartment threading, make sure the DB components you rely on are
> >> thread
> >> >safe. The ones I use are not, and so I have to implement
> everything
> >> as
> >> >'ciSingleInstance'.

> >> >I hope this helps to reassure you that what you are trying to do
> is
> >> >possible (if I understand you correctly).

> >> >Good luck,

> >> >Steve

> >> >Terry wrote:

> >> >> I wonder if anyone can help me a little here...

> >> >> I want to write non visual activex object that manipulates sql
> >> server.

> >> >> All I want to do is to post a single record to an sql server
> table.

> >> >> Nothing complicated.  In fact I want to be able to pass
> parameters
> >> to
> >> >> an SQL Server stored procedure.

> >> >> Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5
> and
> >> all

> >> >> the knobs and SP's.

> >> >> Why an activex oblect - because I want to be able to use this
> >> object
> >> >> from delphi, MS Office and/or the internet/intranet using active

> >> >> server pages.

> >> >> If it is not possible then Delphi is surely doomed as a
> development

> >> >> environment and this would be a shame since the thought of
> having
> >> to
> >> >> work with VB does not appeal one little bit.

> >> >> Hope springs eternal

Re:Accessing SQL Server via activex written in Delphi


Thanks Steve.  I'll let you know how it goes...

Best Regards,

David Montgomery
www.directfile.com

Quote
Steve Midgley wrote in message <[email protected]_anti.spam.com>...
>Compliments will get you everywhere. Here's a link to a simple ASP
>Delphi COM Server. There is a delphi project and two sample ASP files
>included. It should compile out of the box. Let me know if it doesn't.
>Make sure you read the instructions in the main pascal file on how to
>configure ASP to run out of process components (this project is one).

>I guess I can't post this zip binary directly to the newsgroup so you
>can get it off of my private web site:

>http://shell6.ba.best.com/~midgley/ASPComSample/ASPComSample.zip

>Hopefully this will help you and others. There are a few advanced topics
>in this project as well as the basics. I've tried to break out
>everything so you can use only what you need. Good luck with this and
>feel free to write me with any questions concerning this thing. I've
>been meaning to write this example for quite some time, so I'm glad you
>gave me the motivation to do it.

>See you,

>Steve

>David Montgomery wrote:

>> Steve,

>> Thanks for the great answer!  What makes usenet such a great resource
>> is
>> that I would have *never* thought to create my own COM server to do
>> this.  I
>> was thinking in a very linear fashion, and you gave me something new
>> to
>> try...

>> I'll let you know how it works.

>> Best Regards,

>> David Montgomery
>> [email protected]*nospamplease*directfile.com

>> PS - If you have your own example, and it's _convenient_ for you,
>> please
>> send it along if you don't mind.  Don't bother if you have to write a
>> specific example.

>> Steve Midgley wrote in message
>> <[email protected]_anti.spam.com>...
>> >Hi,

>> >You should be able to integrate Delphi with your Interbase ODBC
>> driver
>> >and ASP. It's almost exactly what I'm doing. I heartily recommend

>> >WWW->ASP->Delphi COM->ODBC->database server

>> >over

>> >WWW->CGI->Delphi->ODBC->database server

>> >ASP provides (as you know) a handy environment for writing your
>> simple
>> >HTML formatting stuff. Writing this in CGI, for me, is like pulling
>> your
>> >own teeth without anesthetic!

>> >Instead, for complex data stuff (where ASP lags because it's so
>> slow),
>> >use a Delphi COM backend that is instantiated by ASP (with
>> >server.createobject).  This COM server can safely connect to the SQL
>> >backend through whatever ODBC technology you want to use (or through
>> >ADO, DAO, RDO or any other way). If Delphi can do it, Delphi COM can
>> do
>> >it too.

>> >Since your ODBC driver is not thread safe, you can't even consider
>> >writing a multi-threaded application, and if it's as bad off as mine,
>> it
>> >won't even support multiple connections to the backend at once (in
>> the
>> >same process space).

>> >This means, if your stuff is dumb like mine, you should write your
>> >Delphi COM server with a 'ciSingleInstance' instantiation model. This

>> >will cost you some ram and general slow down, but it's better than
>> not
>> >working, right? :)

>> >For ASP, this is actually better than a single-threaded apartment
>> (STA),
>> >because you actually get the appearance of a multi-threaded apartment

>> >(MTA) (multiple ASP worker threads can make calls into your COM
>> objects
>> >simultaneously).

>> >The other info that will help is that you should instantiate your
>> ODBC
>> >drivers manually in the .Initialize procedure of your COM server, and

>> >you should destroy them in the .destroy destructor (make sure to call

>> >the inherited method too!). Don't drop them onto the main form if you

>> >can possibly avoid it. It will likely give you architecture problems
>> >down the road when you decide to ditch your current ODBC drivers for
>> >thread-safe ones.

>> >If you still want a very simple, Delphi COM-ASP sample, let me know
>> and
>> >I'll cook one up. I don't think my actual database code won't be of
>> much
>> >interest to you since it's highly customized--er, generic :)

>> >Good luck, and let me know if I can help,

>> >Steve Midgley

>> >David Montgomery wrote:

>> >> Steve,

>> >> Can you provide any samples of what you've done.  I'm trying to
>> >> replace an
>> >> ASP script which I have been using to populate a Crystal Report
>> based
>> >> on an
>> >> Interbase back-end.

>> >> The Interbase ODBC driver isn't thread-safe, so I figure I'll need
>> to
>> >> re-write my ASP script as a Delphi CGI.

>> >> TIA,

>> >> David Montgomery
>> >> [email protected]*no*spam*directfile.com

>> >> Steve Midgley wrote in message
>> >> <[email protected]_anti.spam.com>...
>> >> >Hi,

>> >> >If by 'non-visual activex object' you mean a COM server, then this
>> is

>> >> >definitely possible, as I have been doing it for some time here.
>> I'm
>> >> not
>> >> >using Delphi's C/S stuff, but the implementation details should be

>> >> >similar for that.

>> >> >I use a third party ODBC component, and I create the connection
>> and
>> >> >query components in the initialize procedure of my COM Server. I
>> >> destroy
>> >> >the objects in the destroy destructor of same. If you want to
>> >> implement
>> >> >apartment threading, make sure the DB components you rely on are
>> >> thread
>> >> >safe. The ones I use are not, and so I have to implement
>> everything
>> >> as
>> >> >'ciSingleInstance'.

>> >> >I hope this helps to reassure you that what you are trying to do
>> is
>> >> >possible (if I understand you correctly).

>> >> >Good luck,

>> >> >Steve

>> >> >Terry wrote:

>> >> >> I wonder if anyone can help me a little here...

>> >> >> I want to write non visual activex object that manipulates sql
>> >> server.

>> >> >> All I want to do is to post a single record to an sql server
>> table.

>> >> >> Nothing complicated.  In fact I want to be able to pass
>> parameters
>> >> to
>> >> >> an SQL Server stored procedure.

>> >> >> Can someone tell me how to do this using Delphi 3 C/S MSSQL6.5
>> and
>> >> all

>> >> >> the knobs and SP's.

>> >> >> Why an activex oblect - because I want to be able to use this
>> >> object
>> >> >> from delphi, MS Office and/or the internet/intranet using active

>> >> >> server pages.

>> >> >> If it is not possible then Delphi is surely doomed as a
>> development

>> >> >> environment and this would be a shame since the thought of
>> having
>> >> to
>> >> >> work with VB does not appeal one little bit.

>> >> >> Hope springs eternal

Other Threads