clooak
asked on
Linq or SQL - Check data from datatable if column data contains a letter "E"
Hey
I am developing a .NET web-app and I am importing a huge amount of data from an excel sheet, to a datatable.
Before I do any changes to the data fetched, I want to make sure that a certain field in the excel, does not contain character "E". If so, stop the import process.
Any idea what this linq query should look like? I have tried numerous of ideas, with no result.
I would rather use an SQL query, but couldnt find a way to query the dataset by using it.
I am developing a .NET web-app and I am importing a huge amount of data from an excel sheet, to a datatable.
Before I do any changes to the data fetched, I want to make sure that a certain field in the excel, does not contain character "E". If so, stop the import process.
Any idea what this linq query should look like? I have tried numerous of ideas, with no result.
I would rather use an SQL query, but couldnt find a way to query the dataset by using it.
ASKER
Splendid perfect! Theres only one problem left which I can't really figure out..
The data i am comparing is looking similar to 124245E2414 notice the E in the middle, I can't get it to convert the entire value to string, so that I can compare it.
Any idea? I have tried setting soemthing like .ToString() so it looks something like
row.Field<string>("Order_n um").ToStr ing().Cont ains("E")
The data i am comparing is looking similar to 124245E2414 notice the E in the middle, I can't get it to convert the entire value to string, so that I can compare it.
Any idea? I have tried setting soemthing like .ToString() so it looks something like
row.Field<string>("Order_n
ASKER
If I changed the
row.Field<double>("Order_n um")
to row.Field<string>("Order_n um").ToStr ing()
Then It works with the E values, but the rest that doesnt have E is still considered as Double will yield error when trying to read them.
So I gotta figure out a way to force the Double/String I am reading to string. Somehow.
row.Field<double>("Order_n
to row.Field<string>("Order_n
Then It works with the E values, but the rest that doesnt have E is still considered as Double will yield error when trying to read them.
So I gotta figure out a way to force the Double/String I am reading to string. Somehow.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Something like the following code snippet should work. Make sure to assign the correct table index.
Open in new window