How can I use real SQL on a DataTable? i.e. not array of rows using a filter... as in DataTable.Sele

D

Dan V.

How can I use real SQL on a DataTable? i.e. not array of rows using a
filter... as in DataTable.Select.

I read at : microsoft.public.dotnet.framework.adonet

"As others have posted: There is no SQL query processor for DataSets. You
can use XPath with an XMLDataDocument built from the DataSet. You can also
perform selections based on criteria, using the Find and
Select methods, and you can create row filters using DataViews."

Is this true?
 
G

Greg Young

yes RowFilters are VERY powerful and more similar to what you might be
looking for ..

xpaths are also very powerful.

neither is "real" sql though.
 
D

Dan V.

After reading some articles I have a better idea.

I basically am creating a utility for myself that allows one to run a SQL
query or Filter on every table in every database in a path (including
subfolders if desired). It basically will be used mostly to find table
names and column names that match a pattern. When at least one row is found
it displays the 'table' in a DataGrid and has a next or quit button type of
thing.

So I am using GetSchema for schema stuff. and have a DataTable. Now how
would I populate a DataGrid?
 
D

Dan V.

I will use code like the following, and use a filter instead to work with
in-line memory data as opposed to running sql over the network again.

DataTable tblSchemaTable =

conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,

new object[] {null, null, null, "TABLE"})

OR

conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,

new object[] {null, null, tblName, null})



// http://www.knowdotnet.com/articles/dataviews1.html

// http://www.knowdotnet.com/articles/expressions.html

DataView dvSchema = tblSchemaTable.DefaultView;

dvSchema.RowFilter = "COLUMN_NAME like '%PCX%'"

if (dvSchema.Count > 0)

MyDataGrid.DataSource = dvSchema;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top