Skip to content

Instantly share code, notes, and snippets.

@KingsleyOmon-Edo
Last active July 11, 2018 03:11
Show Gist options
  • Save KingsleyOmon-Edo/00298e93019032d2e55d4bbec35ce1ee to your computer and use it in GitHub Desktop.
Save KingsleyOmon-Edo/00298e93019032d2e55d4bbec35ce1ee to your computer and use it in GitHub Desktop.
using MySql.Data.MySqlClient;
using System.Data;
public class Admin
{
private DataTable GetDatabase(string sqlQuery)
{
DataTable returnedData = new DataTable();
MySqlConnection connection = new MySqlConnection();
MySqlDataAdapter adapter = new MySqlDataAdapter();
MySqlCommand command = new MySqlCommand();
string connectionString = string.Empty;
connectionString = "Server=localhost;Port=3306;Database=snowbakedb;Uid=root;Pwd=prayer";
connection.ConnectionString = connectionString;
connection.Open();
command.CommandText = sqlQuery;
adapter.SelectCommand = command;
command.Connection = connection;
adapter.Fill(returnedData);
connection.Close();
adapter.Dispose();
return returnedData;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment