Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,408 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,457 people online right now. Registration is fast and FREE... Join Now!




Merging and update database

 
Reply to this topicStart new topic

Merging and update database, try to merge and two databases

shelby poston
15 Oct, 2008 - 05:46 AM
Post #1

New D.I.C Head
*

Joined: 15 Apr, 2008
Posts: 5

CODE
OleDbConnection mySqlConn = new OleDbConnection(SqlConnString);
            OleDbCommand mySqlCom = mySqlConn.CreateCommand();

            OleDbConnection mySqlConn2 = new OleDbConnection(Sql2ConnString);
            OleDbCommand mySqlCom2 = mySqlConn2.CreateCommand();

            mySqlCom.CommandText = "SELECT * FROM OISInt_Contact";
            OleDbDataAdapter mySqlAd = new OleDbDataAdapter();
            mySqlAd.SelectCommand = mySqlCom;
            DataSet myDS = new DataSet();

            
            mySqlConn.Open();
            mySqlAd.Fill(myDS, "OISInt_Contact");


            mySqlCom2.CommandText = "SELECT * FROM OISInt_Contact";      
            OleDbDataAdapter mySqlAd2 = new OleDbDataAdapter();
            mySqlAd2.SelectCommand = mySqlCom2;
            DataSet myDS2 = new DataSet();
            mySqlConn2.Open();
            mySqlAd2.Fill(myDS2, "OISInt_Contact");
            mySqlConn.Close();
            mySqlConn2.Close();
            
            myDS2.Merge(myDS, true, MissingSchemaAction.AddWithKey);

            foreach (DataTable dt in myDS2.Tables)
            {                
                    foreach (DataRow dr in dt.Rows)
                    {                      
                        foreach (DataColumn dc in dt.Columns)
                        {
                        }
                    }
            }

            mySqlAd2.SelectCommand.Connection = mySqlConn2;
      mySqlAd2.InsertCommand = new OleDbCommand(String.Format("OISInt_ContactInsert", myDS.Tables));
            mySqlAd2.InsertCommand.CommandType = CommandType.StoredProcedure;
            mySqlAd2.Update(myDS2, "OISInt_Contact");



when I do a step into all data is in the data set and it merges but goes not commit or accept changes to the database I trying to move it to.

This post has been edited by shelby poston: 15 Oct, 2008 - 06:50 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:11PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month