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

Portable SQL Server connection

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I've developed a number of applications using Delphi against a SQL Server database. Each time I come up against the same problem but always use a work-around (as I know it works). I'm trying to get a better solution to the issue.
I make use of a TDatabase component.
I set up an ODBC connection (call it 'ODBC_1') to the required SQL Server database (call it 'DATABASE_1')
If I set the 'AliasName' property of the TDatabase component to be 'ODBC_1', not entering any additional parameters and not setting the 'Driver Name' (mutually exclusive with the setting of the 'AliasName'), the application operates fine on the machine it was developed on. If I move the compiled program to another machine, with SQL Server database running and ODBC connection 'ODBC_1' set up in the same way I sometimes get the error that the connection is not trusted and the connection fails - causing my application to fail.
How can I set up the TDatabase such that I can run the application on any machine (which has access to the appropriate database and has the ODBC connection set up) when I move the executable between machines.
I currently have a procedure that sets up the TDatabase component according to a password (for access of SQL Server) as entered by the user. I set the 'Driver Name' of the TDatabase to be 'SQL Server' and then set the parameters 'DATABASE NAME=DATABASE_1', 'USER NAME=sa', 'ODBC DSN=ODBC_1', 'PASSWORD=' + password entered.
This then allows the application to be run on any machine as required but its not as simple as I would like.
What settings do I need to apply in the TDatabase component to allow me to achieve this ?
Thanks in advance
Steve
 
hi Steven

I don't understand why it doesn't connect if the odbc name is the same, all I can think of is the other user's username isn't in the database group, especially if logging in with NT authentication.

You're good with SQLServer so I guess you've checked this and this message isn't useful.

When you've solved it, will you let me know?

thanks
lou
 
The ODBC connection on the various machines is set up in the same manner and all make use of SQL Server authentication ('sa' profile - albeit using it inappropriatley).
The ODBC connection tests successful on all the machines - so this is not the issue.
Should I be setting the 'AliasName' property in the TDatabase component or setting the 'DriverName' and then setting the series of Parameters ?
Any thoughts ?
Thanks again
Steve
 
My old project used TDatabase, SQLServer 7 and ODBC. In the TDatabase, I had the name set to whatever it was setup as in SQLExplorer and an Alias name set to something different. All DB components pointing to the Alias name set in the TDatabase. I didn't set anything for the Driver name.

I also had Login prompt and Keep Inactive connection checked too. My Parameter overrides were empty.

I didn't have any additional parameters set.

Sorry, I can't be more helpful.

lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top