TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Farhan Shariff
NA
933
241.7k
Sorting Datatable
Mar 19 2014 5:32 AM
I am using a text parser to import a .csv file to Datatable
I want to sort the table from smallest to largest.
There are negative values in the table so type conversion has to be considered how to I approach the problem.
I tried table4.Columns.Add("datecolumn1",typeof(double)); it says A column named 'datecolumn1' already belongs to this DataTable.
private static DataTable GetDataTabletFromCSVFile3(string csv_file_path3)
{
DataTable table4 = new DataTable("Refrence");
using (TextFieldParser csvReader = new TextFieldParser(csv_file_path3))
{
csvReader.SetDelimiters(new string[] { "," });
csvReader.HasFieldsEnclosedInQuotes = true;
string[] colFields = csvReader.ReadFields();
foreach (string column in colFields)
{
DataColumn datecolumn1 = new DataColumn(column);
datecolumn1.AllowDBNull = true;
table4.Columns.Add(datecolumn1);
//filterExp = filterExp + datecolumn1 + " asc ,";
}
while (!csvReader.EndOfData)
{
string[] fieldData = csvReader.ReadFields();
//Making empty value as null
for (int i = 0; i < fieldData.Length; i++)
{
if (fieldData[i] == "")
{
fieldData[i] = null;
}
}
table4.Rows.Add(fieldData);
}
Reply
Answers (
2
)
how to find the external device connecting r not using mscom
set absolute values for Expression