Can SelectCountMethod in ObjectDataSource accept input?

ben_ng

Member
Joined
Sep 13, 2007
Messages
18
Location
Singapore
Programming Experience
1-3
Hi,
I am new to tableadapters and I am trying out this example to do custom paging and stuff with tableadapters:
http://www.asp.net/learn/data-access/tutorial-26-vb.aspx

What they did inside was to simply select all products in the database table. What if I need to get a count of the products with name starting with,say 'amd%'. If I were to use call the 'SelectCountMethod' in the ObjectDataSource,would it be able to accept functions with input parameters?
Like say,SelectCountMethod=TotalNumberOfProducts(anyword) ?

How do I do this? Any help is much appreciated!
Thanks!
 
Last edited by a moderator:
If you want to get a count of records from the database you can execute a query like this:
VB.NET:
SELECT COUNT(*) FROM MyTable WHERE MyColumn LIKE 'amd%'
If you already have all the data in a DataTable then you can do this:
VB.NET:
Dim recordCount As Integer = myDataTable.Select("MyColumn LIKE 'amd%'").Length
 
In future, please post ASP questions in the ASP section of the forums, not the vb section
 
Back
Top