public static PutInDatabase getInstance() { if (instance == null) { instance = new PutInDatabase(); } return instance; }
private void button1_Click(object sender, EventArgs e) { progressBar1.Value = 0; ParserClass parser = new ParserClass(); PutInDatabase pidb = new PutInDatabase(); try { //pidb.setConnectionString("db2-pc","sa","sa"); Records[] temp = parser.uitvoer(pathFileShow.Text); try { progressBar1.Maximum = temp.Length; richTextBox1.Text = " "; int counter = 0; if (temp.Length > 0) { foreach (Records s in temp) { pidb.addListToDatabase(s, pcname, username, password); if (richTextBox1.Text == null) { richTextBox1.Text += s + "\n"; } else { richTextBox1.AppendText(s + "\n"); } richTextBox1.ScrollToCaret(); counter++; progressBar1.Value++; } System.Windows.Forms.MessageBox.Show("Data added to database"); this.Close(); this.Dispose(); } else { MessageBox.Show("Nothing in textfile"); } } catch { MessageBox.Show("Text file not in the correct format"); } } catch(Exception E) { System.Windows.Forms.MessageBox.Show("File in use"+ E ); } }