SQL.INI

forum.td.development (2005-2010)
Paul

SQL.INI

Post by Paul » 22 Apr 2009, 22:52

 Posted by:  Paul 

Hello,

Is it possible to connect to database servers that have not been
pre-defined in my SQL.INI file - i.e., use a connection string in my code?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Jim McNamara

SQL.INI

Post by Jim McNamara » 23 Apr 2009, 14:14

 Posted by:  Jim McNamara 

What version of TD? You can use OLEDB (see SqlCreateSession(...) and
SqlCreateStatement(...) and system variable SqlUDL.

Rainer Ebert

SQL.INI

Post by Rainer Ebert » 23 Apr 2009, 16:06

 Posted by:  Rainer Ebert 

In case of OLEDB: I would not recommend to use the system variable SqlUDL
and better manually use SqlCreateSession() and SqlCreateStatement(). At
least with TD 4.2 and SB 11.0.2 SP3 there are stability problems using
SqlUDL (we got silly SQL errors and implemented our own session handling).

Regards,
Rainer

Jim McNamara

SQL.INI

Post by Jim McNamara » 23 Apr 2009, 19:52

 Posted by:  Jim McNamara 

I also pass on SqlUDL since it's only needed once in an app to create the
session.

Rainer Ebert

SQL.INI

Post by Rainer Ebert » 24 Apr 2009, 10:19

 Posted by:  Rainer Ebert 

We tried to use it in an multi-database-application where we connect native
to a SQLBase database and via OLEDB to a Sql Server database. In this
application we change SqlUDL, SqlDatabase, SqlUser and SqlPassword to the
needs of the particuar connect. If you do many OLEDB connects/disconnects in
a short time, you get an error. We've than changed to SqlCreateSession() and
SqlCreateStatement() instead of SqlUDL and SqlConnect() and now there is no
problem any more. Note that the problem occured deep within business logic
classes which had nothing to do with OLEDB. ???

Regards,
Rainer

Paul

SQL.INI

Post by Paul » 24 Apr 2009, 20:23

 Posted by:  Paul 

I am using a very old version of TD - 2.1.

I want to allow the user to input an ODBC connection string to connect to
one of many MySQL databases (it will be saved for the next time) but the
list of databases keeps extending thus making it very difficult to keep
updating the SQL.INI file. I was wondering whether it was possible to
define the ODBC connection details programmatically.

Any inspiration?


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Jim McNamara

SQL.INI

Post by Jim McNamara » 24 Apr 2009, 22:20

 Posted by:  Jim McNamara 

Can you see the Sal functions SqlCreateSession(...) and
SqlCreateStatement(...)? If you can you should be good to go. I don't
recall what version OLE DB was introduced, but it has been a long time.

Paul

SQL.INI

Post by Paul » 26 Apr 2009, 22:14

 Posted by:  Paul 

Jim,

Thanks for the information. Yes, I do have SqlCreateSession and
SqlCreateStatement functions. I shall read up and try them out.

Paul.


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Steve Leighton
Site Admin
Site Admin
New Zealand
Posts: 65
Joined: 05 Mar 2017, 20:57
Location: Tauranga, New Zealand

Re: SQL.INI

Post by Steve Leighton » 24 Jan 2019, 23:48

For anyone reading this and considering the ODBC v OLE DB for SQLServer conundrum ..... wef April 2018, Microsoft have just 'undeprecated' their OLE DB Driver for SQL Server versions 2012 to 2017, and released a brand new OLE DB driver which will 'be developed further in preference to ODBC' .
I am testing right now against TD6 and TD7 - so far Ok.

The variable SqlUDL in place of SqlUser, SqlDatabase and SqlPassword can contain a .udl file name with the SqlServer connection string in it, or the string itself. A .udl file is easiest, just create a .txt file, rename it to .udl , double click the .udl file, and a connection wizard allows easy configuration.

So you don't need a Sql.ini or a DSN at all. So much easier to deploy.

Go here for details / download: https://blogs.msdn.microsoft.com/sqlnat ... ql-server/

Go here for my sample: https://forum.tdcommunity.net/viewtopic.php?f=6&t=45816
Best wishes
Steve
Bankside Systems Ltd. ( UK ♦ Australia ♦ New Zealand )
www.banksidesystems.co.uk

Return to “td.development”

Who is online

Users browsing this forum: No registered users and 0 guests