Click here to Skip to main content
14,883,098 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need datatable only + large data is der


dt = SQLHelper.ExecuteDataTable(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, DBConstants.Dummmy_DummyParameters, parm);
        dt.TableName = "DataTable";

        StringBuilder objStringBuilder=new StringBuilder();
        XmlWriter objXmlWriter = XmlWriter.Create(objStringBuilder);
        objStandardPivotGridData.DataString = Convert.ToString(objStringBuilder);
        foreach (DataColumn dc in dt.Columns)
            var field1 = dc.ToString();
            string Datatype = dc.DataType.Name.ToString();

----------Service Call--------------
XmlReader objXmlReader = XmlReader.Create(GenerateStreamFromString(Convert.ToString(objPFMS_ToolClient.GetGridData(objReportsModel, Session_Fetch.Fetch_UserDetails).DataString).Replace("DocumentElement", "root")));

              DataSet ds = new DataSet();
              foreach (DataColumn dc in ds.Tables["DataTable"].Columns)
                  var field1 = dc.ToString();
                  string Datatype = dc.DataType.Name.ToString();

What I have tried:

I am trying do WCF service call and i need to pass datatable because of dynamic databinding, i m doing
so In WCF service BLL and i am coverting datatable to xml string.
my return datatype is string.

In controller I am doing conversion of XML to Dataset
In the above scenario, I need to maintain the original datatype....Need help.. :)
Updated 14-Apr-16 21:34pm
Sinisa Hajnal 15-Apr-16 2:37am
And what is the issue? You describe what you're doing, but there is no mention of any error text or description of what happens when you convert.
Member-515487 15-Apr-16 3:33am
Definition was getting change datatype after xml conversion

1 solution

XSD is solution

DataTable table = new DataTable();
           table.TableName = "Sushant";
           table.Columns.Add("Dosage", typeof(int));
           table.Columns.Add("Drug", typeof(string));
           table.Columns.Add("Patient", typeof(string));
           table.Columns.Add("Date", typeof(DateTime));

           // Here we add five DataRows.
           table.Rows.Add(25, "Indocin", "David", DateTime.Now);
           table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
           table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
           table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
           table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
           StringBuilder sb = new StringBuilder();
           StringBuilder sb1 = new StringBuilder();
           XmlWriter tw= XmlWriter.Create(sb);
           tw = XmlWriter.Create(sb1);
           for (int j = 0; j < table.Columns.Count; j++)

               Console.WriteLine(table.Columns[j].ColumnName + "', type = "
                                 + table.Columns[j].DataType.ToString());

           DataTable dt = new DataTable();
           string strsb = Convert.ToString(sb);
           string strsb1 = Convert.ToString(sb1);
           TextReader tr = new StringReader(strsb);
           XmlReader xr = XmlReader.Create(tr);
           tr = new StringReader(strsb1);
           xr = XmlReader.Create(tr);
           for (int j = 0; j < dt.Columns.Count; j++)

               Console.WriteLine(dt.Columns[j].ColumnName + "', type = "
                                 + dt.Columns[j].DataType.ToString());

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900