Discussion:
Help creating a connection at runtime error
(too old to reply)
Nando
2008-03-12 14:59:38 UTC
Permalink
Hi all,

I'm trying to create a connection at run time but it is not working.

This is the code

Connection:= TSQLConnection.Create(nil);
Connection.ConnectionName := 'myConnection';
Connection.DriverName := 'MSSQL';
Connection.LibraryName := 'dbxmss30.dll';
Connection.VendorLib := 'oledb';
Connection.GetDriverFunc := 'getSQLDriverMSSQL';
Connection.Params.Add('drivername=MSSQL');
Connection.Params.Add('schemaoverride=%.dbo');
Connection.Params.Add('hostname=myServer');
Connection.Params.Add('database=myDatabase');
Connection.Params.Add('user_name=myUser');
Connection.Params.Add('password=myPassword');
Connection.Params.Add('blobsize=-1');
Connection.Params.Add('localecode=0000');
Connection.Params.Add('mssql transisolation=ReadCommited');
Connection.Params.Add('os authentication=False');
Connection.Params.Add('prepare sql=False');
Connection.LoginPrompt:= False;
Connection.Open; -->> SQL State: HYT00, SQL Error Code:0 Time out error.

If I create the connection at desing time with the same properties and
parameters it works fine.

What am I doing wrong?

Thank you in advance for any help.

Nando
Rich Werning
2008-03-13 20:13:32 UTC
Permalink
What version of Delphi, 2007? If so, you need to realize that even though
you are specifing the parameters in code, when you open up the connection it
reads the information from dbxdrivers.ini and dbxconnetions.ini - even if
you don't want it to.

You can rename those files to avoid them being used, but then you get a
memory leak (I think they fixed it in the december update). Or you can
verify that the MSSQL driver in dbxdrivers.ini is configured correctly, and
that you connection name in dbxconnections is configured the same. If you
change the driver name to something like "MSSQL (LOCAL)' and the connection
name to 'myconnection(local)', so that it can't find either of those in the
ini files, then it will use the settings you have and not override them with
values from the ini files.
--
Rich Werning
TIP Technologies, Inc.
Post by Nando
Hi all,
I'm trying to create a connection at run time but it is not working.
This is the code
Connection:= TSQLConnection.Create(nil);
Connection.ConnectionName := 'myConnection';
Connection.DriverName := 'MSSQL';
Connection.LibraryName := 'dbxmss30.dll';
Connection.VendorLib := 'oledb';
Connection.GetDriverFunc := 'getSQLDriverMSSQL';
Connection.Params.Add('drivername=MSSQL');
Connection.Params.Add('schemaoverride=%.dbo');
Connection.Params.Add('hostname=myServer');
Connection.Params.Add('database=myDatabase');
Connection.Params.Add('user_name=myUser');
Connection.Params.Add('password=myPassword');
Connection.Params.Add('blobsize=-1');
Connection.Params.Add('localecode=0000');
Connection.Params.Add('mssql transisolation=ReadCommited');
Connection.Params.Add('os authentication=False');
Connection.Params.Add('prepare sql=False');
Connection.LoginPrompt:= False;
Connection.Open; -->> SQL State: HYT00, SQL Error Code:0 Time out error.
If I create the connection at desing time with the same properties and
parameters it works fine.
What am I doing wrong?
Thank you in advance for any help.
Nando
Nando
2008-03-14 13:22:06 UTC
Permalink
Thank you for your posting.
Post by Rich Werning
What version of Delphi, 2007?
CodeGearT Delphi® 2007 for Win32® R2 Version 11.0.2902.10471
Post by Rich Werning
... when you open up the connection it reads the information from
dbxdrivers.ini and dbxconnetions.ini - even if you don't want it to.
Should I deploy those files with my application?
If yes, in which path do they be copied to?

Nando
Rich Werning
2008-03-14 17:02:54 UTC
Permalink
The standard way of deploying dbexpress apps that use dbxconnections.ini and
dbxdrivers.ini is to save the file in the directory that your applications
are in. I believe the search path is: registry key, local folder, windows
search path. So it would depend on what works for you. For out apps we
don't use the dbx ini files, we have different ones that we use and maintain
as we need those for other uses also.

If you can use the ini files, it makes sense to. By configuring them on
your development system you can use the explorer in the IDE, and all of the
settings load fine during run time.
--
Rich Werning
TIP Technologies, Inc.
Post by Nando
Thank you for your posting.
Post by Rich Werning
What version of Delphi, 2007?
CodeGearT Delphi® 2007 for Win32® R2 Version 11.0.2902.10471
Post by Rich Werning
... when you open up the connection it reads the information from
dbxdrivers.ini and dbxconnetions.ini - even if you don't want it to.
Should I deploy those files with my application?
If yes, in which path do they be copied to?
Nando
Nando
2008-03-14 19:32:16 UTC
Permalink
Rich, thank you very much

Nando.
Post by Rich Werning
The standard way of deploying dbexpress apps that use dbxconnections.ini
and dbxdrivers.ini is to save the file in the directory that your
applications are in. I believe the search path is: registry key, local
folder, windows search path. So it would depend on what works for you.
For out apps we don't use the dbx ini files, we have different ones that
we use and maintain as we need those for other uses also.
If you can use the ini files, it makes sense to. By configuring them on
your development system you can use the explorer in the IDE, and all of
the settings load fine during run time.
--
Rich Werning
TIP Technologies, Inc.
Post by Nando
Thank you for your posting.
Post by Rich Werning
What version of Delphi, 2007?
CodeGearT Delphi® 2007 for Win32® R2 Version 11.0.2902.10471
Post by Rich Werning
... when you open up the connection it reads the information from
dbxdrivers.ini and dbxconnetions.ini - even if you don't want it to.
Should I deploy those files with my application?
If yes, in which path do they be copied to?
Nando
Loading...