using MySql.Data.MySqlClient;
using System.Data;
namespace WindowsFormsApp1
{
public class Class1
{
static public string connectionSctring = "DataBase = new_schema; DataSource = localhost; User = ****; Password = ****";
static public MySqlConnection sqlConnection = new MySqlConnection(connectionSctring);
static public MySqlCommand sqlCommand = new MySqlCommand();
static public MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sqlCommand);
static public DataTable table = new DataTable();
static public bool Connection()
{
try
{
sqlConnection.Open();
sqlCommand.Connection = sqlConnection;
return true;
}
catch
{
System.Windows.Forms.MessageBox.Show("Ошибка");
return false;
}
}
static public void Disconnection()
{
sqlConnection.Close();
}
static public DataTable FillTheTable()
{
sqlCommand.CommandText = "SELECT * FROM new_table";
sqlCommand.ExecuteScalar();
table.Clear();
dataAdapter.Fill(table);
return table;
}
}
}