Good day buddies.
Please I have a problem and I hope you guys can help me out.
I am working on VB.NET 2012 application that connects to ms sql server. I want to allow users to select the installed sever instance of their chioce so I have a module that present installed server instances for the user to select from.
After a selection is made, the module will then create the necessary database objects. My code raise error when it tries to create ms sql login in for the current user. I found that the error is raised by connectionstring(firstSQL) but I do not know to resolve it.
Please find below details of my code.
connectionStr = "Data Source=" & lstLocalSevers.SelectedItem.ToString & ";DataBase=;Integrated Security=SSPI"
Dim firstSQL As New SqlConnection(connectionStr)
<pre>'create login for the current user
Dim sql As New SqlCommand("if not exists (select NAME FROM sys.login_token" & ") CREATE LOGIN " & us, firstSQL)
The error: 'Incorrect syntax near '-'. The '-' is part of the computer name(name-PC) and the instance is name-PC\SQLEXPRESS and the onnection string generate from the pc is '
"Data Source=name-PC\SQLEXPRESS;DataBase=;Integrated Security=SSPI"
Thanks in advance for your help