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

Customizing login with TSQLConnection 2

Status
Not open for further replies.

soothin

Programmer
Jan 12, 2006
1
0
0
US
Can anyone tell me how to properly pass the login information to the TSQLConnection component from a custom created dialog box?
I know that to pass login information to TSQLConnection, the LoginPrompt must be set to “true”, and the login information is passed through the “OnLogin” event handler, but the problem is that the OnLogin handler is not reading the information.
If I set LoginPrompt to “true” and leave the OnLogin handler blank, I get the default login prompt and will not have any problem. Any and all authorized users can login; however, when I set the LoginPrompt to “true” and add the information passed from a custom login prompt, I get the custom login dialog box, but it ignores the information completely. The application still launches, but it logs in with the params values entered in design mode.
I've been battling this problem for a couple weeks, any assistance would be greatly appreciated.
 
You need to use the TSQLConnection's ConnectionString.
From Help File said:
Description

Set ConnectionString to specify the information needed to connect the ADO connection component to the data store. The value used for ConnectionString consists of one or more arguments ADO uses to establish the connection. Specify multiple arguments as a list with individual arguments separated by semicolons.

ADOConnection1->ConnectionString = "Provider=ProviderRef;Remote Server=ServerRef";

At design-time, select from the list of available ADO database connections invoked from the Object Inspector.

A connection string may be saved to file for later use. Specify only the name of such a file in ConnectionString to reuse a saved connection string.

The connection string may also contain login information such as user ID and password, for automated logins.

When explicitly passing login information through either the Open method or the ConnectionString, the LoginPrompt property should be set to false to prevent an unnecessary login dialog.

ADO supports the following four arguments for connection strings. Any other arguments (such as a user ID and password) are not processed by ADO and simply passed on to the provider.

Argument Meaning
Provider The name of the provider to use for the connection.
File name The name of a file containing connection information.
Remote Provider The name of the provider to use for a client-side connection.
Remote Server The path name of the server to use for a client-side connection.

For example, my ConnectionString may look like "Provider=SQLOLEDB.1;Password=mypassword;Persist Security Info=True;User ID=myuser;Initial Catalog=MINE;Data Source=SQL".

Look at faq101-5282 on how to use MS's PromptDataSource. I take the string returned from this API and send it to the ConnectionString.

James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top