Azure CREATE LOGIN fails

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
djb
Posts: 8
Joined: Fri 24 Mar 2006 23:26

Azure CREATE LOGIN fails

Post by djb » Sun 07 Aug 2016 18:53

I'm using SDAC version 6.10.21 with an Azure SQL Database.

When I issue the following query I get an error:

Code: Select all

aLoginName := 'NewUserName';
aPassword := 'NewUserPassword1!';
Query.SQL.Text := 'CREATE LOGIN :LoginName WITH PASSWORD = :Password';
Query.ParamByName('LoginName').AsString := aLoginName;
Query.ParamByName('Password').AsString := aPassword;
Query.Execute;
Incorrect param near '@P1'.

HOWEVER, this code DOES work:

Code: Select all

Query.SQL.Text := 'CREATE LOGIN NewUserName WITH PASSWORD = ''NewUserPassword1!''';
Query.Execute;
Any ideas why passing parameters to this query would be causing a problem?

The code is in exactly the same place and is connected to the master database.

As a side note, calls to Query.FinalSQL don't seem to give the full query with the parameters expanded.

Thanks!

ViktorV
Devart Team
Posts: 2299
Joined: Wed 30 Jul 2014 07:16

Re: Azure CREATE LOGIN fails

Post by ViktorV » Mon 08 Aug 2016 11:17

This question is not related to SDAC functionality, but to specificities of Azure SQL Database architecture.
The issue is that CREATE LOGIN and ALTER LOGIN won't take the variable. The way around this is to use Dynamic SQL:https://social.msdn.microsoft.com/Forum ... ransactsql

djb
Posts: 8
Joined: Fri 24 Mar 2006 23:26

Re: Azure CREATE LOGIN fails

Post by djb » Wed 10 Aug 2016 23:58

Thanks, I couldn't find that information anywhere else. Absolute nonsense, but that's Azure...

ViktorV
Devart Team
Posts: 2299
Joined: Wed 30 Jul 2014 07:16

Re: Azure CREATE LOGIN fails

Post by ViktorV » Thu 11 Aug 2016 08:03

Thank you for being interested in our products.
If you have any questions concerning our products, please don't hesitate to contact us - and we will try to help you resolve them.

Post Reply