Jump to content
  • Welcome to AutoLanka

    :action-smiley-028: We found you speeding on AutoLanka Forums without any registration! If you want the best experience, please sign in. Safe driving! 

Recommended Posts

This message box comes up everytime I try to create or access a database. Tried stackexchange & even one of my lecturers went blank seeing it. Tried re-installing visual studio and that didn't help either.

Can anyone here lend a hand?

Thanks in advance!

20191202_193339.jpg

Share this post


Link to post
Share on other sites

Well C# is not really my area of expertise but is the server running at all? Can you go to the event viewer and see if there are any startup errors for the MSSQL service or any related services?

  • Like 1

Share this post


Link to post
Share on other sites

Did you try to google this? , I mean not the whole error at least part of it.

 

  • Like 1

Share this post


Link to post
Share on other sites

That means your C# application is unable to reach the machine running SQL server. Looks like you're using a local database file. 

This is not an issue with your Visual Studio installation. Your client application basically fails to connect to SQL server. If it were a physical database server, this error means that there's a network issue between the machine executing the C#, and the database server. But because your database is local, it is either because:

1. Your connection string is wrong 

2. You're trying to use a wrong system library to connect to the database. 

Happy to help if you can zip your code and share it on Google Drive or something. I'm sure it's a very easy fix. 

 

Edited by Davy
  • Like 1

Share this post


Link to post
Share on other sites

which version of visual studio are you using? can you post your current connection string here? Maybe the connection string is wrong or contains invalid parameters and values.

  • Like 1

Share this post


Link to post
Share on other sites

Install SQL Server Management Studio. First try connecting to the SQL server from there. If that doesn't work, try changing the network configuration for SQL Server. i.e. enable Shared Memory/ TCI/IP. Then try enabling SQL server browser.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Malkoba said:

Install SQL Server Management Studio. First try connecting to the SQL server from there. If that doesn't work, try changing the network configuration for SQL Server. i.e. enable Shared Memory/ TCI/IP. Then try enabling SQL server browser.

It's a Local DB file by the looks. Not a server instance. So Visual Studio can be used as it has native support for Local Database files. 

Share this post


Link to post
Share on other sites

It cannot be a local DB file. The message itself contain that it cannot connect to the SQL server instance. if he is using a DB file (i.e. SQLite), then he should use an ODBC connection. not SQL connection. The drivers for these 2 are different.

Actually, Even in SQL server, its referred to as Local DB when you are accessing it form the machine itself.

Edited by Malkoba

Share this post


Link to post
Share on other sites
16 hours ago, Malkoba said:

It cannot be a local DB file. The message itself contain that it cannot connect to the SQL server instance. if he is using a DB file (i.e. SQLite), then he should use an ODBC connection. not SQL connection. The drivers for these 2 are different.

Actually, Even in SQL server, its referred to as Local DB when you are accessing it form the machine itself.

It's a generic error message when something is wrong with the connection.

I'm not saying that it's SQLite. It's SQL Server Express LocalDB which is a lightweight version of SQL Express shipped with Visual Studio. It doesn't have complex instances running all the time like a full SQL Server instance. Instead, it spins up a new instance by looking at the connection string which points to an MDF file. You don't use ODBC with LocalDB, you use SqlConnection within System.Data.SqlClient. 

Anyway, let's wait for @□AVANTE□ to confirm. 

Share this post


Link to post
Share on other sites

Thanks for the info everyone! I was ill these few days & had a bad sprain, have to try the solutions now. Also, about the connection string @Davy, is there any chance the application could start with a misguided string? I'm a noob so still figuring things out. Pressing the 'service based database' button in 'new item' is enough to bring about the warning.

Share this post


Link to post
Share on other sites
15 hours ago, □AVANTE□ said:

Thanks for the info everyone! I was ill these few days & had a bad sprain, have to try the solutions now. Also, about the connection string @Davy, is there any chance the application could start with a misguided string? I'm a noob so still figuring things out. Pressing the 'service based database' button in 'new item' is enough to bring about the warning.

As I expected, you are trying to add a new LocalDB database file, but Visual Studio seems to be having trouble trying to connect to your MSSQLLocalDB.

It sounds like it is an installation issue after all. Which Version of Visual Studio are you using? I know you said that you tried to repair the installation, but did you check if the "SQL Server Data Tools" option within the "Data Storage and processing" section of the installation options is checked? Screenshot below:

image.thumb.png.21c378e743bb0fb0d5272b23ecd5cd43.png

Keep us posted on how it goes.

Share this post


Link to post
Share on other sites
23 hours ago, Davy said:

As I expected, you are trying to add a new LocalDB database file, but Visual Studio seems to be having trouble trying to connect to your MSSQLLocalDB.

It sounds like it is an installation issue after all. Which Version of Visual Studio are you using? I know you said that you tried to repair the installation, but did you check if the "SQL Server Data Tools" option within the "Data Storage and processing" section of the installation options is checked? Screenshot below:

image.thumb.png.21c378e743bb0fb0d5272b23ecd5cd43.png

Keep us posted on how it goes.

I'm using 2015. I'll try this and let you know! Thanks again!

Share this post


Link to post
Share on other sites

Am I in "AutoLanka" forum or somewhere in "StackOverFlow"...?????

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Register for a new account in our community. It's easy and FREE!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×