Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Created August 4, 2024 23:48
Show Gist options
  • Save jrichardsz/ea3cfb46ecfbf795a248d7b092c97550 to your computer and use it in GitHub Desktop.
Save jrichardsz/ea3cfb46ecfbf795a248d7b092c97550 to your computer and use it in GitHub Desktop.
csharp c# crud - mysql

Select

// dotnet add package MySql.Data --version 9.0.0

using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

string query = "SELECT 1;";
string config = "server=localhost;username=root;password=;database=json";

MySqlConnection connection = new MySqlConnection(config);
MySqlCommand command = new MySqlCommand(query, connection);
connection.Open();
MySqlDataReader Reader = command.ExecuteReader();

while (Reader.Read())
{
  Console.WriteLine(Reader[0].ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment