Last active
July 11, 2018 03:11
-
-
Save KingsleyOmon-Edo/00298e93019032d2e55d4bbec35ce1ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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