Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
-
FredS
- Posts: 272
- Joined: Mon 10 Nov 2014 17:52
Post
by FredS » Thu 28 Jan 2016 17:32
Just a heads-up.
Using a DataModule within a thread I got "Windows logins are not supported in this version of SQL Server"
from an Azure db.
Now I know it works because I have used threads before via:
Code: Select all
TUniConnection.Create(nil, ConnectString).
After some monkeying around I could get the DataModule thread to work "consistently"only after removing all SpecificOptions, ProviderName, Database and Macros and using:
Code: Select all
UniConnection.connect(ConnectString)
-
azyk
- Devart Team
- Posts: 1119
- Joined: Fri 11 Apr 2014 11:47
- Location: Alpha Centauri A
Post
by azyk » Tue 02 Feb 2016 09:00
We can't reproduce the reported error according to your recommendations. Let us know the value the ConnectString you are using for connection to Azure SQL Database.
-
FredS
- Posts: 272
- Joined: Mon 10 Nov 2014 17:52
Post
by FredS » Tue 02 Feb 2016 17:34
azyk wrote:We can't reproduce the reported error according to your recommendations. Let us know the value the ConnectString you are using for connection to Azure SQL Database.
I should add the test was from my local machine to an Azure db.
Code: Select all
'Provider Name=SQL Server;Provider=SQLOLEDB.1;Data Source=<ServerName>.DATABASE.WINDOWS.NET;Initial Catalog=PA;Force Create Database=False;User ID=fred;Password=<Pwd>;Login Prompt=False'
Maybe I should add what I had that caused the issue:
Code: Select all
object UniConnection: TUniConnection
ProviderName = 'InterBase'
Database = 'D:\My Projects\db\PA.FDB'
SpecificOptions.Strings = (
'InterBase.ClientLibrary=C:\ProgramData\Firebird\fb3\fbclien' +
't.dll'
'InterBase.Charset=UTF8'
'InterBase.UseUnicode=True'
'SQL Server.Authentication=auWindows'
'InterBase.Role=RDB$ADMIN'
'SQL Server.ForceCreateDatabase=False'
'InterBase.ForceUnloadClientLibrary=True'
'SQL Server.Provider=prSQL')
Options.AllowImplicitConnect = False
Options.KeepDesignConnected = False
Options.DefaultSortType = stCaseInsensitive
Macros = <
item
Name = 'True'
Value = 'TRUE'
Condition = 'InterBase'
end
item
Name = 'True'
Value = '1'
Condition = 'SQLServer'
end
item
Name = 'False'
Value = 'FALSE'
Condition = 'InterBase'
end
item
Name = 'False'
Value = '0'
Condition = 'SQLServer'
end
item
Name = 'FROMRDBDatabase'
Condition = 'SQLServer'
end
item
Name = 'FROMRDBDatabase'
Value = 'FROM RDB$Database'
Condition = 'InterBase'
end
item
Name = 'concat'
Value = '||'
Condition = 'InterBase'
end
item
Name = 'concat'
Value = '+'
Condition = 'SQLServer'
end
item
Name = 'First'
Value = 'First'
Condition = 'InterBase'
end
item
Name = 'First'
Value = 'Top'
Condition = 'sQLServer'
end>
Username = 'SYSDBA'
LoginPrompt = False
end
-
azyk
- Devart Team
- Posts: 1119
- Joined: Fri 11 Apr 2014 11:47
- Location: Alpha Centauri A
Post
by azyk » Wed 03 Feb 2016 08:52
The provided dfm code for UniConnection contains a line that sets Windows Authentication for the SQL Server provider:
Code: Select all
'SQL Server.Authentication=auWindows'
Since the Authentication parameter is not specified in the used connection string, then on connection this UniConnection will use Windows Authentication. To use SQL Server Authentication, set the Authentication connection string parameter to 'Server'. For example:
Code: Select all
'Provider Name=SQL Server;Provider=SQLOLEDB.1;Data Source=<ServerName>.DATABASE.WINDOWS.NET;Initial Catalog=PA;Force Create Database=False;User ID=fred;Password=<Pwd>;Login Prompt=False;Authentication=Server'
-
FredS
- Posts: 272
- Joined: Mon 10 Nov 2014 17:52
Post
by FredS » Wed 03 Feb 2016 16:41
azyk wrote:The provided dfm code for UniConnection contains a line that sets Windows Authentication for the SQL Server provider
The connectionstring comes from the main connection and there I have this code:
Code: Select all
if UserPrefs.ReadBool('Database', 'UseWindowsAuth', True) then begin
SpecificOptions.Values['SQL Server.Authentication'] := 'auWindows';
Username := EmptyStr;
Password := EmptyStr;
end else begin
SpecificOptions.Values['SQL Server.Authentication'] := 'auServer';
Username := UserPrefs.ReadString('Database', 'Login', EmptyStr);
Password := EnCrypt(<pwd>, ecUnlock);
end;
Shouldn't the Connectionstring which we pass on to threaded connections override any dfm entries?
-
azyk
- Devart Team
- Posts: 1119
- Joined: Fri 11 Apr 2014 11:47
- Location: Alpha Centauri A
Post
by azyk » Fri 05 Feb 2016 13:00
When you set a value for TUniconnection.ConnectString, it will override only mentioned connection string parameters of this connection instance.
-
FredS
- Posts: 272
- Joined: Mon 10 Nov 2014 17:52
Post
by FredS » Fri 05 Feb 2016 16:53
azyk wrote:When you set a value for TUniconnection.ConnectString, it will override only mentioned connection string parameters of this connection instance.
OK, so for threading we pass the main connection string to any threads, but if design time parameters are set which are NOT explicitly set in the connection string we need to clear them.