Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Data
- {
- private string conString;
- private MySqlConnection conn;
- private MySqlDataAdapter adapter;
- private MySqlCommand command;
- //private DataTable table;
- public Data()
- {
- conString = MakeConString();
- conn = new MySqlConnection(conString);
- command = new MySqlCommand();
- }
- private string MakeConString()
- {
- string pconString;
- string host = "webdog";
- string database = "repairs";
- string user = "root";
- string password = "password";
- pconString = string.Format("Data Source={0}; Database={1}; User ID={2}; Password={3}", host, database, user, password);
- return pconString;
- }
- public MySqlCommand getCommand(string query)
- {
- command.Connection = conn;
- command.CommandText = query;
- return command;
- }
- public MySqlDataAdapter getAdapter(string query)
- {
- adapter = new MySqlDataAdapter();
- adapter.SelectCommand = getCommand(query);
- return adapter;
- }
- public MySqlDataReader getReader(MySqlCommand command)
- {
- return command.ExecuteReader();
- }
- public void connOpen()
- {
- conn.Open();
- }
- public void connClose()
- {
- conn.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement