Skip to content

Difference between same database.

Wajid Usman

Asked Jul 10, 2014, 12:44 PM EDT3 answers
Share
LinkedInX
hi, i am using a local database in c# visual studio and make a insert, delete and update record system for this i have created two database database 1 and database 2. In one form i use the database 1 and in another form i used database 2. My both database colums and data type values are same both have 4 coloums and have same name in it. The problem is that when i insert a record in one form which means that in database 1 it automatically inserted into database 2 and same for all other 2 operations( delete and update). Please tell me how can i solve this so that i am very thank full to you

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    First of all I would like to know the reason behind using two databases. Two forms and two dbs, what's the rationale behind it. 

    Anyway, ideally it's not possible that query fired over 1 db inserts record into other db. It's very strange. Can you please paste code for any operation say Insert?

    twitter @sumitjolly
    0
  • 0
    Sumit, i used one database in form which is called Items Avaliable and the other database in the form which is Items Sell both have same coloums.

    yaa sure i paste my source code of form 1 and form 2 both.


    thanks sumit for help :)

    Source Code form 1 (Insert):

     private void btninsert_Click(object sender, EventArgs e)
            {
                if (txtparticular.Text.Length > 0 && txtquantity.Text.Length > 0)
                {
                    int k = DBConn_SI.drugInsert_SI(txtparticular.Text, Int32.Parse(txtquantity.Text), Int32.Parse(txtrate.Text), DateTime.Parse(txtdatetime.Text));
                    if (k > 0)
                    {
                        dgvDrugs_SI.DataSource = DBConn_SI.getAllDrugs();
                    }
                    else
                    {
                        MessageBox.Show("No record inserted");
                    }
                }
                else
                {
                    MessageBox.Show("Please fill in ID and Name of the drug");

                }

    Source Code of form 2 (Insert):
    private void btninsert_Click(object sender, EventArgs e)
       {
           if (txtparticu.Text.Length > 0 && txtquanti.Text.Length > 0)
           {
               int k = DBConn.drugInsert(txtparticu.Text, Int32.Parse(txtquanti.Text), Int32.Parse(txtrate.Text), DateTime.Parse(txtdatetime.Text));
               if (k > 0)
               {
                   dgvDrugs.DataSource = DBConn.getAllDrugs();
               }
               else
               {
                   MessageBox.Show("No record inserted");
               }
           }
           else
           {
               MessageBox.Show("Please fill in ID and Name of the drug");
           }
       }
    0
  • 0
    What's the connection string of 
    DBConn_SI
    & 
    DBConn


    Please paste code for 
    DBConn_SI.drugInsert_SI &  DBConn.drugInsert

    0