none
how refresh database chnages to dataset.xsd when some rows added to database? RRS feed

  • Question

  • Hi everybody

    I use Dataset.xsd for showing rdlc report; I could design rdlc report and show it easily; the problem when occurred that I wanted to add some rows during runtime to database; the changes don't reflect to dataset and rdlc report; and only insert to dataset.xsd when allpication restart; please help me; how can I update datset.xsd by new records that added to database at runtime?

    thanks

     


    • Edited by hadilionsonn Sunday, June 14, 2015 12:43 PM
    • Moved by Youjun Tang Monday, June 15, 2015 6:49 AM more appropriate
    Sunday, June 14, 2015 12:41 PM

Answers

  • Can I ask why you creating the DataSet instance, why don't you call the DataTable directy via DataSet.DataTable, something like below:

    DataSet1.DataTable1.Rows.Add(1, "fouad", 100);
                DataTable dt = DataSet1.DataTable1;
                reportViewer1.Visible = true;
                reportViewer1.LocalReport.ReportPath = @"C:\Projects\Solution1\WindowsFormsApplication1\Report1.rdlc";
                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));
    
                this.reportViewer1.RefreshReport();


    Fouad Roumieh

    • Marked as answer by hadilionsonn Thursday, June 25, 2015 8:39 AM
    Monday, June 15, 2015 1:02 PM

All replies

  • Hi hadilionsonn,

    As your issue is related to rdlc report, I'm moving your thread to a more appropriate forum--Report forum for help. thanks for your understanding.

    Regards,
    Youjun Tang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, June 15, 2015 6:48 AM
  • Is your DataSource set programmatically or via the designer? And did you implement any code to refill your DataSet on refresh?

    The report viewer has an event ReportRefresh, inside that event you can implement code to refill he DataSet with the latest updates from the DB.

    Check this thread there is c# code example at the end of.


    Fouad Roumieh

    Monday, June 15, 2015 6:52 AM
  • I used designer for adding dataset. and after adding new rows, I fill dataset by code, but just return initial rows, also end of code I usd ReportRefresh, but it doesn't work;

    it's seemed after insert rows by sqlcommand and fill the dataset.datatable the changes wont be done into dataset; because the count of rows doesn't change, until close and reopen program :/ 

     
    Monday, June 15, 2015 7:13 AM
  • I used designer for adding dataset. and after adding new rows, I fill dataset by code, but just return initial rows, also end of code I usd ReportRefresh, but it doesn't work;

    it's seemed after insert rows by sqlcommand and fill the dataset.datatable the changes wont be done into dataset; because the count of rows don't change, until close and reopen program :/ 

     
    Could you please share your code on this function to verify?

    Fouad Roumieh

    Monday, June 15, 2015 7:22 AM
  •         SqlCommand scInsert = new SqlCommand("Insert Into GlassProducing (Barcode, ThicknessCode, ColorCode, ReadyToProduce, LayerName, LayerInfo, TotalGlassLot, OrderCode, GlaasLot, Status, ProductionStageCode, InputTime, InputTimeText, FactoryCode, ProducingTurn, LayerCode,ComputerId, Width, Height) Values(@Barcode, @ThicknessCode, @ColorCode, @ReadyToProduce, @LayerName, @LayerInfo, @TotalGlassLot, @OrderCode, @GlaasLot, @Status, @ProductionStageCode, @InputTime, @InputTimeText, @FactoryCode, @ProducingTurn, @LayerCode,@ComputerId,@Width,@Height)", DataLibrary.Connection);
    .
    .
    .
    scInsert.ExecuteNonQuery();
    //the changes applied to database correctly
    
    GlassesDataDataSet dataset = new GlassesDataDataSet();
    
    GlassesDataDataSetTableAdapters.LabelTableAdapter sqldaLabel = new GlassesDataDataSetTableAdapters.LabelTableAdapter();
    
    //We Use this sqldataadapter for returning filtered rows and works fine in rdlc report; but just show initial rows
    sqldaLabel.Fill(dataset.Label, OrderCode, 0, 999, (byte)LayerCode);
    MessageBox.Show(dataset.Label.Rows.Count.ToString());
    
    //messagebox just show count of initial rows

    //and I use this code to show report
    
    
                bool doen = false;
                while (!doen)
                {
                    try
                    {
                        this.LabelTableAdapter.Fill(GlassesDataDataSet.Label, OrderCode, 0, 9999, LayerCode);
                        doen = true;
                    }
                    catch (Exception)
                    {
                    }
                }
    
    
    
                this.reportViewer1.RefreshReport();
    


    Monday, June 15, 2015 7:42 AM
  • But this is not an SQLDataAdapter, because there is no Fill method with such signature similar to the one you're using?

    Fouad Roumieh

    Monday, June 15, 2015 7:54 AM
  • it is regular sqldataadapter with some parameters for filtering the result; because I want to constrain on the results to show in rdlc report

    Could you please tell me How do you filter the result of dataset to show in rdlc report?

    you can go to builder of dataset and add parameters and then automatically, parameters  will be added as variants of adapter.fill() method 
    Monday, June 15, 2015 8:01 AM
  • Can you call the dataset.Label.Rows.Clear(); before the fill and let me know what result you will get?

    Fouad Roumieh

    Monday, June 15, 2015 8:42 AM
  • thank you for your helping

    I call clear method but the results are the same; and changes are not applied.

    I Deleted the parameters from adapter and the number of rows is not changed again;

    like this: sqldaLabel.Fill(dataset.Label);

    during debug when I check preview data of dataset.Label; the new rows are there; but in the sample dataset constructed from the GlassesDataDataSet  class like the code mentioned, are constant, without any changes.  


    Monday, June 15, 2015 9:17 AM
  • Try calling the dataset.AcceptChanges(); after the fill, this should commit the changes and after that check the DS via debugger.

    And if you added the params both DT and DS are  not updating when you check via debugger?


    Fouad Roumieh

    Monday, June 15, 2015 9:44 AM
  • I checked AcceptChanges() now and before but doesn't affect it; 

    If I used Parameters like mentioned, the changes will be shown during debug in dataset designer as good as Fill without parameters;  

    sorry for bad skill of English :(

    Monday, June 15, 2015 9:54 AM
  • Can I ask why you creating the DataSet instance, why don't you call the DataTable directy via DataSet.DataTable, something like below:

    DataSet1.DataTable1.Rows.Add(1, "fouad", 100);
                DataTable dt = DataSet1.DataTable1;
                reportViewer1.Visible = true;
                reportViewer1.LocalReport.ReportPath = @"C:\Projects\Solution1\WindowsFormsApplication1\Report1.rdlc";
                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));
    
                this.reportViewer1.RefreshReport();


    Fouad Roumieh

    • Marked as answer by hadilionsonn Thursday, June 25, 2015 8:39 AM
    Monday, June 15, 2015 1:02 PM
  • I meant on fill:

    sqldaLabel.Fill(GlassesDataDataSet.Label, OrderCode, 0, 999, (byte)LayerCode);


    Fouad Roumieh

    Monday, June 15, 2015 1:08 PM
  • Yes, this method works; But I've inserted rows by sql command to database; and according to this method it needs add rows to dataset separately;

    I think there is a way that update the dataset from last changes of database

     
    Monday, June 15, 2015 1:11 PM
  • Yes, this method works; But I've inserted rows by sql command to database; and according to this method it needs add rows to dataset separately;

    I think there is a way that update the dataset from last changes of database

     

    The instance of the DS that you creating is a separate one that is used at the same moment by the report. And if you want the updates to be reflected, you should update the DS report instance and that's what I did in the code sent.

    Let me know if you still need more help on this.


    Fouad Roumieh

    Tuesday, June 23, 2015 12:34 PM