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! 

Help: C# is killing me


AVANTE

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

Link to comment
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
Link to comment
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. 

Link to comment
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
Link to comment
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. 

Link to comment
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.

Link to comment
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.

Link to comment
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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

AutoLanka Cars For Sale

Post Your Ad Free [Click Here]



×
×
  • Create New...