Object refrence not set to an instant of an object
public MySqlConnection connection; public void DBConnect() { Initialize(); } private void Initialize() { string datasource = ""; string initialcatalog = ""; string uid = ""; string pwd = ""; string connectionstring; connectionstring = "SERVER='" + datasource + "';DATABASE='" + initialcatalog + "';UID='" + uid + "';PASSWORD='" + pwd + "'"; connection = new MySqlConnection(connectionstring); } private bool OpenConnection() { try { connection.Open(); return true; } catch (Exception ex) { switch (ex.Number) { case 0: System.Windows.Forms.MessageBox.Show("Cannot Connect to server. Contact administrator"); break; case 1045: System.Windows.Forms.MessageBox.Show("Invalid Username/Password for mysql, Please try again"); break; } return false; } }
Initialise
DBConnect
Initialize
OpenConnection
void
OpenConnection()
Initialize()
connectionstring = "SERVER=" + datasource + ";DATABASE=" + initialcatalog + ";UID=" + uid + ";PWD=" + pwd;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)