Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to write from a Daemon to MsSQLServer

Status
Not open for further replies.

Dunsany

Programmer
Aug 8, 2003
5
FR
Hi,

I wrote a server application (with Delphi6) few month ago. When i decided to turn it into an Application Service, there were no trouble at all, except one: it doesn't write on MsSQLServer 2000. I Changed security properties (Windows & SQL Server) on my SQL server. My connection string is good (with the Password and so on). At design time, the build connection test works, but not at running time. I use ADO Components (connection & query).
If someone tried to write with a daemon & ADO component on MSSQLServer2k or have an idea...
(excuse my english, i'm french.. :)

best regards
 
Hi,

you must call Coinitialize() (put ActiveX unit in uses list) before activating ADO components and Couninitialize() at service destruction.

--------------------------------------
What You See Is What You Get
 
I've got an 'Undeclared Identifier', which Library use CoInitialize() ?
 
activeX unit (like I said)...

--------------------------------------
What You See Is What You Get
 
Sorry, i read too fast... But it still doesn't work.
 
then you'll have to show some code, maybe we can help :)

--------------------------------------
What You See Is What You Get
 
Query is simple as that (it's a test with Ms Northwind DB):

var
RegionID: integer;
RegionDescription: string;
begin
RegionID:=5;
RegionDescription:='Green grass & pretty girls !';

With ADOQuery2 do
begin
SQL.Clear;
SQL.Add('SELECT * FROM Region');
Active:= True;

Insert;
FieldByName('RegionID').Value:=RegionID;
FieldByName('RegionDescription').Value:=RegionDescription;
Post;
end;

ps: it's an SQLServer access to DB so Connection string has a Password. Connection works with the Query Analyser and at design time.
This code works with an executable application. So where is the bug ?
 
I don't believe the problems lies into your query.

show me the service initialization part , I mean the part were the service thread is created an where you set the ADOconnection.active property to true...

--------------------------------------
What You See Is What You Get
 
I maked it fast. So there is just a TADOQuery component with the connection string, and your CoInitialize(nil) in ServiceCreate with a call to a timer. The OnTime procedure (of the timer) is writing the DB with the query. And of course a CoUnInitialize() in ServiceDestroy. Nothing else to declare...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top