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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Portable TDatabase component for SQL Server

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I have an issue whereby when I move my development application from one machine to another I need to modify the parameters in the TDatabase component (for the connection to my SQL Server 7.0 database)
I usually create an ODBC connection (ODBCConnect1) and point this to the appropriate SQL Server database (call it Database1)
I then add my TDatabase component to my global datamodule, give it a name, set the Driver to be 'SQL server' and then set the Params within the component as follows :
DATABASE NAME=Database1
USER NAME=sa
ODBC DSN=ODBCConnect1
PASSWORD=password
If I now move the application to another machine (running against a SQL Server with a different password, obviously the connection fails.
I then have to re-edit these Params to be correct for the machine (and SQL Server) I'm running the application on / against.
Ideally I'd like to be in a position where I could move my application (and source files) between machine (and similarly to client machines) without having to rebuild the application with the 'password' appropriate for the SQL Server I'm running up against.
I've tried not setting the Params in the TDatabase and setting the 'AliasName' to be the name of the ODBC connection (ODBCConnect1) but when I then move the application to a different machine I get an error that the connection cannot be made as it is not a trusted connection (cannot log on the 'sa' user).
Anyone have any thoughts on this ?
THanks in advance
Steve
 
Hi,

Why donn't you put the variables in an ini file and read them at startup. After reading the variables you activate the connection.

Steph [bigglasses]
 
Thought about that - and do practise something similar in some cases.
The problem is more so in the development stages when I move the files from machine to machine. After moving them I need to reset these params.
Ideally I'd like it to use the ODBC connection which is fed with the appropriate server name and password on each of the machines as required.
Similarly this would be the case when putting the application onto client machines on distribution.
Thanks so far.
Any further thoughts ?
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top