Connect to Sql Database and get data C#
- Download Nuget package Mysql.Data
- Import namespace MySql.Data.MySqlClient
- Construct the connectionstring eg., server=localhost;user=root;password=secret;database=myDatabase
Employees has three rows
EmployeeId, FirstName and LastName
var connectionString = $"server={dbCon.Server};user={dbCon.UserName};password={dbCon.Password};database={dbCon.DatabaseName}";
Comments
Post a Comment