Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DatabaseConnection
- {
- //database stuff
- private const String SERVER = "127.0.0.1";
- private const String DATABASE = "hospital_database";
- private const String UID = "root";
- private const String PASSWORD = "root";
- private static MySqlConnection dbConn;
- public static void InitializeDB()
- {
- MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
- builder.Server = SERVER;
- builder.UserID = UID;
- builder.Password = PASSWORD;
- builder.Database = DATABASE;
- String connString = builder.ToString();
- builder = null;
- Console.WriteLine(connString);
- dbConn = new MySqlConnection(connString);
- Application.ApplicationExit += (sender, args) => {
- if (dbConn != null)
- {
- dbConn.Dispose();
- dbConn = null;
- }
- };
- MySqlCommand cmd = new MySqlCommand(query, dbConn);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement