none
REsults Set from Dataset is missing when directly refered data set from an xml RRS feed

  • Question

  • HI Friends,

        I have a requirement in which i have to read the data from xml to dataset . Some how i am missing the data from some columns though i have data in excel for such columns

         1) In some columns of Data set the values are some are integer some are String for such columns we are missing the whole data in those columns

    Below is the code we used for reading csv file accordingly

    Please suggest are we missed any thing in the below code

    public static DataTable ReadDataFromCSVFile(string aCSVFilePath, string aFileExtension, ref string aErrorMessage)
      {
       DataTable dtCSVData = new DataTable();
       try
       {
        string sFileName = aCSVFilePath.Substring(aCSVFilePath.LastIndexOf("\\") + 1);
        string sSqlQuery = "SELECT * FROM [" + sFileName + "]";
        string sConnectionStr = string.Empty;
        if (aFileExtension.ToLower().Trim().StartsWith(".xls"))
         sConnectionStr = string.Format("{0}{1};{2}", xlsOLEDBConnection, aCSVFilePath.Substring(0, aCSVFilePath.LastIndexOf("\\")), ExtendedProperties);
        else if (aFileExtension.ToLower().Trim().StartsWith(".xlsx"))
         sConnectionStr = string.Format("{0}{1};{2}", xlsxOLEDBConnection, aCSVFilePath.Substring(0, aCSVFilePath.LastIndexOf("\\")), ExtendedProperties);
        else if (aFileExtension.ToLower().Trim().StartsWith(".csv"))
         sConnectionStr = string.Format("{0}{1};{2}", xlsOLEDBConnection, aCSVFilePath.Substring(0, aCSVFilePath.LastIndexOf("\\")), ExtendedProperties);
        OleDbConnection oleConn = new OleDbConnection(sConnectionStr);
        using (oleConn)
        {
         OleDbDataAdapter oleda = new OleDbDataAdapter(sSqlQuery, oleConn);
         oleda.Fill(dtCSVData);
         //dtCSVData.Columns["Is there a Sub-Assembly BOM that needs separate demand forecasting due to SBR Structure (Such as TO Can)"].MaxLength = 100;
         DataView dv = new DataView();
         dv = dtCSVData.DefaultView;
         dv.Sort = "Product PN Status Desc";
         dtCSVData = dv.ToTable();
        }
        return dtCSVData;
       }
       catch (Exception Ex)
       {
        aErrorMessage = Ex.Message.ToString();
        return dtCSVData;
       }
      }


    Ravishankar Maduri MCTS,MCPD,MCP



    Friday, November 30, 2012 10:52 AM

Answers

  • Hi Ravishankar,

    Sorry I confuse with your explanation, you asking that you want to read the data from xml to dataset but your example code is to read data from CSV.

    For read data from xml to dataset, you can use this link as example code: http://msdn.microsoft.com/en-us/library/fx29c3yd.aspx

    If I misunderstand, please explain more and better if you can provide sample code and data (.csv or .xml).

    Thank you.


    Regards,
    Christian HL
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • Marked as answer by Alexander Sun Tuesday, December 11, 2012 2:30 AM
    Tuesday, December 4, 2012 4:10 AM