Thursday, March 8, 2012

.NET FW SDK QuickStart SQL-Express Error: Msg 102 ... Incorrect syntax.

Hi,

I have followed the steps from the .NET FW SDK QuickStart Configuration (C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Samples\Setup\html\ConfigDetails.htm), and have got an error message trying to grant the ASP.NET User account access to the databases by the command sqlcmd -E -S (local)\SQLExpress -Q "sp_grantlogin LEONEW\ASPNET" where LEONEW is my local machine name, and the ASPNET account exists in the Users group.

I am getting the error message: Msg 102, Level 15, State 1, Server LEONEW\SQLEXPRESS, Line 1
Incorrect syntax near '\'.

Please help if you know how to resolve this. Thanks in advance.

Alex.

Did you try putting apostrophes around the login name:

'LEONEW\ASPNET'

|||I have tried with no success sqlcmd -E -S (local)\SQLExpress -Q "sp_grantlogin N' LEONEW\ASPNET'".|||

Do you get the same error?

What about

sqlcmd -E -S (local)\SQLExpress -Q "sp_grantlogin 'LEONEW\ASPNET'"

If I use it without the apostrophes I get the same error as you:

Msg 102, Level 15, State 1, Server <...>, Line 1
Incorrect syntax near '\'.

If I add the apostrophes the command succeeds.

|||You are absolutely right. Thanks.

No comments:

Post a Comment