AVANTE Posted December 2, 2019 Posted December 2, 2019 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! Quote
ramishkad Posted December 2, 2019 Posted December 2, 2019 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? 1 Quote
john cooper Posted December 2, 2019 Posted December 2, 2019 Did you try to google this? , I mean not the whole error at least part of it. 1 Quote
Davy Posted December 2, 2019 Posted December 2, 2019 (edited) 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 December 2, 2019 by Davy 1 Quote
amsandun Posted December 3, 2019 Posted December 3, 2019 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. 1 Quote
Malkoba Posted December 3, 2019 Posted December 3, 2019 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. 1 Quote
Davy Posted December 3, 2019 Posted December 3, 2019 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. Quote
Malkoba Posted December 3, 2019 Posted December 3, 2019 (edited) 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 December 3, 2019 by Malkoba Quote
Davy Posted December 3, 2019 Posted December 3, 2019 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. Quote
AVANTE Posted December 5, 2019 Author Posted December 5, 2019 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. Quote
Davy Posted December 6, 2019 Posted December 6, 2019 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: Keep us posted on how it goes. Quote
AVANTE Posted December 7, 2019 Author Posted December 7, 2019 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: Keep us posted on how it goes. I'm using 2015. I'll try this and let you know! Thanks again! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.