By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,610 Members | 935 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,610 IT Pros & Developers. It's quick & easy.

Apply a filter with DataAdapter.Fill

P: n/a
I'm using a typed dataset and would like to retrieve a specific table but
filtering the rows returned (no point in getting more than what you need,
right?). The problem is that the .Fill method of the DataAdapter will fill
the DataTable with all the rows in the table. I tried using a sqlCommand to
no avail.

How can I fill a typed DataTable with filtered rows? Something like
MyDA.Fill(MyDTable, "CustomerID=1")
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
Can't you use a WHERE clause in your query?

"Manuel" <No****@NoMailLand.com> wrote in message
news:Nu********************@giganews.com...
I'm using a typed dataset and would like to retrieve a specific table but
filtering the rows returned (no point in getting more than what you need,
right?). The problem is that the .Fill method of the DataAdapter will fill
the DataTable with all the rows in the table. I tried using a sqlCommand
to no avail.

How can I fill a typed DataTable with filtered rows? Something like
MyDA.Fill(MyDTable, "CustomerID=1")

Nov 21 '05 #2

P: n/a
This what I'm using now. How can I get the DataTable using a query?

-----------------------
Dim myCnn As New Data.SqlClient.SqlConnection("TheConnectionString" )
Dim myDA As New MyDBTableAdapters.CustomersTableAdapter
myDA.Connection = myCnn
Dim tblCustomers As New MyDB.CustomersDataTable
myDA.Fill(tblCustomers)
myCnn.Close()
-----------------------

"Marina" <so*****@nospam.com> wrote in message
news:uf**************@TK2MSFTNGP10.phx.gbl...
Can't you use a WHERE clause in your query?

"Manuel" <No****@NoMailLand.com> wrote in message
news:Nu********************@giganews.com...
I'm using a typed dataset and would like to retrieve a specific table but
filtering the rows returned (no point in getting more than what you need,
right?). The problem is that the .Fill method of the DataAdapter will
fill the DataTable with all the rows in the table. I tried using a
sqlCommand to no avail.

How can I fill a typed DataTable with filtered rows? Something like
MyDA.Fill(MyDTable, "CustomerID=1")


Nov 21 '05 #3

P: n/a
I believe that You can do this two ways.

You should be able to set your query in the data adapter's Select
Command to select only those rows that you need.

Another thing you should be able to do is use a dataview.

Example from the Visual Studio.Net Help

The following code example creates a view that shows all the products
where the units in stock is less than or equal to the reorder level,
sorted first by supplier ID and then by product name.

[Visual Basic]

Dim prodView As DataView = New DataView(prodDS.Tables("Products"), _
"UnitsInStock <= ReorderLevel",
_
"SupplierID, ProductName", _
DataViewRowState.CurrentRows)

Nov 21 '05 #4

P: n/a
> You should be able to set your query in the data adapter's Select
Command to select only those rows that you need.
This is true but every time I modify the .xsd file (add a table or anything)
all my changes to the code are lost because the IDE rebuilds the entire
file. Is there any way of preventing this?
Another thing you should be able to do is use a dataview.


All DataView examples I've read so far make use of a DataTable already
filled and my purpose is filter the records retrieved, not filter them
*after* they're fetched.

"magic man" <as*******@nj.rr.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.