+ 1
Need help with connecting SQL database with c# using visual studio
I have Microsoft SQL server management studio using SQLexpress v 13 and vb is 2017. When I try to connect to the server it gets connected.but when I try to access tables and read or write in them error pops up saying: Exception unhandled System.Data.SqlClient.SqlelException:'A network-related or instance-specific error occured while establishing a connection to SQL server.the server was not found or was not accessible. Verify that the instance name is correct and that SQL server is configured to allow remote connections.(provider: SQL Network interface, error:50- Local Database Runtime error occured.specific localdb instance name is invalid.)'
7 Answers
+ 8
Maybe you didn't install the SQL package correctly...
I had in this sort of problems too
It's better to reinstall it
+ 3
Hey bro check your connection string, if you use sql authentication
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
on myServerAddress, write the name of your installed instance (by default it's .\SQLEXPRESS for SQL Server Express edition). Initial catalog = your database name, you'll see it in SSMS on the left after connecting. The rest speaks for itself.
Otherwise You will need to omit username and password for windows authentication and add Integrated Security=SSPI.
0
Check name of database instance in connection string. You can connect to database in visual studio and copy correct connect string
0
As I said it's getting connected but am not able to perform actions on it.like I was trying to access a test table and show it's data in a message box.i have created break points to show message on completion.so after connection is successful I get a message confirming that. but when I use sql data adaptor or sql command, program goes till con.open() [con is the database connection object] where the error pops up
0
Moreover is my SQLexpress version compatible with the vb version I have??
0
Please can u guide me to do so
0
I also think that is the issue but I have no clue what m looking at