P
P
Popou2021-09-09 16:19:02
.NET
Popou, 2021-09-09 16:19:02

Why is ADO.Net not connecting?

What's wrong with my connection? Line :
"Data Source=127.0.0.1,3306;Network Library=DBMSSOCN;Initial Catalog=game;User ID=root;Password=root"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis, 2021-09-16
@den_labs

https://metanit.com/sharp/adonet/2.2.php - read about the parameters and better throw off the error

V
Victor P., 2021-09-16
@Jeer

How do you work with the database and what is the database in general, ms sql?
If you create tables through sql management studio, how do you connect to the database?
Try to connect to this server (localdb)\mssqllocaldb with Windows username and password. If suitable, then use it in the connection string
Connecting via DataSource was previously in the .net framework via the web config. I haven't looked into it too much, maybe they are the same. In .net core, connection strings are written in appsettings.json like this:
"ConnectionStrings": {
"AppConnection": "Server=(localdb)\\mssqllocaldb;Database=game;Trusted_Connection=True;MultipleActiveResultSets=true"
}
Here the screw login/password is used. If you created your own user, then instead of Trusted_Connection=True; type in User ID=root;Password=root;
An additional question, why do you need ado.net at all when there is an entity framework?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question