1

I am running Visual Studio 2017 with SQL Server Object Explorer. I have been unable to connect to a local SQL database, although I copied the connection string directly from the SQL Server properties window. I created a tiny test project just to work on making this connection work, but nothing I try is working. Any suggestions would be greatly appreciated.

My Connection String:

(localdb)\MSSQLLocalDB;Initial Catalog=SportsStore;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False

Error I am receiving:

Keyword not supported: '(localdb)\mssqllocaldb;initial catalog'. at System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) at System.Data.SqlClient.SqlConnection..ctor(String connectionString, SqlCredential credential) at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at TestWebApp_DotNetFramework.index.btnTestDBConn_Click(Object sender, EventArgs e) in c:\users...

2
  • That's not a valid connection string. You need something like Server:. Commented Oct 23, 2017 at 18:02
  • Thanks. I have corrected my connection string, and now I'm getting a 'better' error message - just need to go through other comments and see what else I'm doing wrong. Thanks again for your help! Commented Oct 23, 2017 at 18:22

3 Answers 3

1

You need to add Data Source attribute too. Your connection string should be like this.

Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=SportsStore;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, don't know how I missed that!
0

I wouldn't copy/paste connection strings directly from MS SQL Server Studio. If you want to connect to LocalDB, then this post is going to help How to connect to LocalDb

Comments

0

Your error code says:

Keyword not supported: '(localdb)\mssqllocaldb;initial catalog'.

Which means that connection string parameter is mistype. if you want more information about connection string parameters, visit this link

try to add "Data Source = " in the begin of your string.

hope that help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.