TMSconnection - strange behavior

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
[email protected]
Posts: 5
Joined: Tue 11 Mar 2014 17:33

TMSconnection - strange behavior

Post by [email protected] » Wed 30 Oct 2019 08:44

for example:
in design i set in object inspector:
loginprompt:=false;
password:='';

then in code:
{mscon:tmsconnection;s:string;}

s:='Provider=TDS;Data Source=localhost;User ID=sa;Password=123';
if mscon.LoginPrompt then showmessage('loginpromt is set to true') else showmessage('loginpromt is set to false');
//here is loginpromt of course false yet
mscon.ConnectString:=s;//here is automatically set loginprompt to true (ignores design settings, in constr there is no reason..)
if mscon.LoginPrompt then showmessage('loginpromt is set to true') else showmessage('loginpromt is set to false');
//here is loginpromt already true, no setting true is in constr, so why is automatically set to true ???
ShowMessage(mscon.ConnectString);
//here is connectionstring with password yet
mscon.Connect;
{here appears loginpromt dialog ! (even though it was set up in the design to false, and not set by connectstr)
in addition, password box is empty even though it was set up by connectsr !
}

paweld
Posts: 19
Joined: Mon 29 Sep 2014 08:56

Re: TMSconnection - strange behavior

Post by paweld » Thu 31 Oct 2019 07:46

Add to ConnectionString: Login Prompt=False
e.g.

Code: Select all

s:='Provider=TDS;Data Source=localhost;User ID=sa;Password=123;Login Prompt=False';
mscon.ConnectString:=s;
if mscon.LoginPrompt then 
showmessage('loginpromt is set to true') 
else 
showmessage('loginpromt is set to false');

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: TMSconnection - strange behavior

Post by Stellar » Thu 31 Oct 2019 11:47

By default, the "Login Prompt" connection parameter is set to True. In your example, you use the connection string that doesn't contain the "Login Prompt" connection parameter, therefore, this parameter is set to the default value True.

[email protected]
Posts: 5
Joined: Tue 11 Mar 2014 17:33

Re: TMSconnection - strange behavior

Post by [email protected] » Thu 31 Oct 2019 17:47

if the logic is such that by assigning a value to mscon.connectstring reset atributes set by design! (which are not set by connstr) to default values, then I don't understand, why password (set by connstr) is missing in loginpromt dialog....that is quite contradictory, that's at least pretty unexpected behavior, I'd rather say a logical error.

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: TMSconnection - strange behavior

Post by Stellar » Mon 04 Nov 2019 13:51

By default, TMSConnectDialog does not automatically put the password into the text box and asks the user to enter it manually. For TMSConnectDialog to put the password into the text box, set the SavePassword property value to True.
For example:

Code: Select all

MSConnectDialog1.SavePassword := True;
MSConnection1.ConnectDialog := MSConnectDialog1;
MSConnection1.Connect;
We intentionally distribute TMSConnectDialog with source code so that the users can change it according to their needs.

[email protected]
Posts: 5
Joined: Tue 11 Mar 2014 17:33

Re: TMSconnection - strange behavior

Post by [email protected] » Mon 04 Nov 2019 18:17

please try this:
MSCon.ConnectString:='Provider=SQLNCLI11.1;Integrated Security=SSPI;Persist Security Info=False;User ID="";Initial Catalog="";Data Source=(localdb)\v11.0;Initial File Name=""';//this is correct connection string working with adoconnection..., this you can generate by windows system dialog.
ShowMessage(MSCon.ConnectString);

you see "..Provider=SQLNCLI.1" - there is LOST "11" from "11.1" and then i got error:..provider not found... (i am working with *.udl files..to store settings).

So assigning connectionstr to msconnection not only reset some settings (unlike ado), but directly corrupt them !!!
- this is big problem !

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: TMSconnection - strange behavior

Post by Stellar » Tue 05 Nov 2019 13:48

Thank you for the information. We fixed the issue with NativeClientVersion connection option being set from ConnectionString, and the fix will be included in the next SDAC build.

[email protected]
Posts: 5
Joined: Tue 11 Mar 2014 17:33

Re: TMSconnection - strange behavior

Post by [email protected] » Tue 05 Nov 2019 14:39

thank you, i found another 2 problems and sent them with code example to support via form.

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: TMSconnection - strange behavior

Post by Stellar » Mon 11 Nov 2019 14:28

We've sent the reply to these additional questions by email.

Post Reply