Esempio n. 1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                Dictionary <string, string> data = new Dictionary <string, string>();
                data["name"]    = textBox1.Text;
                data["email"]   = textBox2.Text;
                data["contact"] = textBox3.Text;
                data["address"] = richTextBox1.Text;
                data["company"] = textBox4.Text;


                conn = DatabaseReader.CreateConnection();
                DatabaseReader.CreateContactTable(conn);
                if (DatabaseReader.InsertContactData(data, conn))
                {
                    MessageBox.Show("Record added successfully !");
                }
                else
                {
                    MessageBox.Show("Unable to add record !");
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DatabaseReader.Close(conn);
                conn = null;
            }
        }