Need help with connecting SQL database with c# using visual studio | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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.)'

17th Feb 2020, 6:08 PM
Indrajeet Singh Yadav
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
17th Feb 2020, 6:44 PM
P. T
P. T - avatar
+ 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.
20th Feb 2020, 8:29 PM
hossein B
hossein B - avatar
0
Check name of database instance in connection string. You can connect to database in visual studio and copy correct connect string
17th Feb 2020, 6:29 PM
༼ つ ◕_◕ ༽つ
༼ つ ◕_◕ ༽つ - avatar
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
17th Feb 2020, 6:41 PM
Indrajeet Singh Yadav
0
Moreover is my SQLexpress version compatible with the vb version I have??
17th Feb 2020, 6:43 PM
Indrajeet Singh Yadav
0
Please can u guide me to do so
17th Feb 2020, 6:44 PM
Indrajeet Singh Yadav
0
I also think that is the issue but I have no clue what m looking at
17th Feb 2020, 6:45 PM
Indrajeet Singh Yadav