Question on DataSet

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manikrag
    New Member
    • Jun 2009
    • 62

    #1

    Question on DataSet

    Hi

    I did not find any solution on internet so pretty basic question here:

    I am trying to copy a dataset to a new dataset by

    ds1 = ds.Copy(); // ds has one row

    After that I am trying to update the SqlDataAdapter by using below statement

    adptr.Update(ds 1.Tables["table name"]);

    I am not facing any issue but the SqlDataAdapter is not adding the new row.


    Please help
  • Manikrag
    New Member
    • Jun 2009
    • 62

    #2
    Urgent dataset question

    Hi

    I did not find any solution on internet so pretty basic question here:

    I am trying to copy a dataset to a new dataset by

    ds1 = ds.Copy(); // ds has one row

    After that I am trying to update the SqlDataAdapter by using below statement

    adptr.Update(ds 1.Tables["table name"]);

    I am not facing any issue but the SqlDataAdapter is not adding the new row.


    Please help

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Please don't double-post your questions. It divides attempts to help you in an organized and cohesive manner. Your threads have been merged

      Comment

      • Manikrag
        New Member
        • Jun 2009
        • 62

        #4
        Sorry about that - I was desperate and was looking for reaction on the issue which i did not get..Point taken anyway!!

        Comment

        • Manikrag
          New Member
          • Jun 2009
          • 62

          #5
          got a better way, sharing it for others who might be OR will be in the same situation where I was..

          System.Data.Sql Client has a class - SqlBulkCopy (http://msdn.microsoft.com/en-us/libr...lbulkcopy.aspx) - this can copy tables as per the select command over servers like a charm..try u will love it :)

          SqlCommand cmd = new SqlCommand("SEL ECT QUERY", dbConn_source);
          dbConn_target.O pen();
          SqlDataReader rdr = cmd.ExecuteRead er();
          // Initializing an SqlBulkCopy object
          SqlBulkCopy sbc = new SqlBulkCopy(dbC onn_target);
          // Copying data to destination
          sbc.Destination TableName = "TableName" ;
          sbc.WriteToServ er(rdr);
          sbc.Close();
          rdr.Close();

          Comment

          Working...