private void connectToSQLServerToolStripMenuItem_Click(object sender, EventArgs e) { var parser = new FileIniDataParser(); if (!File.Exists(Database.ODBCFile)) { File.Create(Database.ODBCFile); } else { IniData data = parser.ReadFile(Database.ODBCFile); Database.SqlIP = data["Connection"]["IP"]; Database.SqlUser = data["Connection"]["SqlUser"]; Database.SqlPass = data["Connection"]["SqlPass"]; if (!string.IsNullOrWhiteSpace(Database.SqlIP) || !string.IsNullOrWhiteSpace(Database.SqlUser) || !string.IsNullOrWhiteSpace(Database.SqlPass)) { SQLmanager sqlhelper = new SQLmanager(); if (!sqlhelper.OpenConnection("Master")) { MessageBox.Show("Could not Connect to " + Database.SqlIP, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { StsStatusLabel.Text = "Connected to " + Database.SqlIP; InitConnection(sqlhelper); GboxMain.Enabled = true; } } } }
void InitConnection(SQLmanager Connection) { sqlhelper = Connection; }