Please Help.

DataTable dtSelectedColumns = dtOriginal.DefaultView.ToTable(false, "Column1", "Column2");

this code retrieve data from a datatable but i want to retrieve like in sql command

 "Select Column1, Column2 From Table where Column1 = "data";

Thank you

This can be partially done using dtSelectedColumns.Select();

However this doesnt use actual SQL to do the selection simply a filter criteria.

For example dtSelectedColumns.Select("Age > 20"); would be the same as running Select * From dtSelectedColumns Where Age > 20. Of course this assumes you have an age column in the table and is purely an example.

So in yourcase it would probably be DataRow[] Results = dtSelectedColumns.Select("Column1Name = 'data'"); replacing Column1Name with the actual column name.

It is also worth looking into Linq querying for datasets, here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.