no dataset in asp.net 2.0?

calvin

Regular
Joined
Nov 6, 2003
Messages
71
Hi,

I'm novice in asp.net 2.0. Since in version 1.1, when i call a select query to check is data available in database table, I use dataset to get the count of row if it is equal to zero, then do something...

However, I found the feature no longer exist in version 2.0. So, Is anyone know how to do such a "function" to check the number of row return?

Appreciate for any help and suggestion. Thank you.


Calvin
 
The DataSet object still exists:

Visual Basic:
[font=Courier New][size=2]System.Data.DataSet
[/size][/font]

Although, I would think that you wouldn't want all of that overhead just to determine if there is data in a database table. Why wouldn't you use something like:

Visual Basic:
Dim con As New System.Data.SqlClient.SqlConnection(<your connection string>)
Dim com As New System.Data.SqlClient.SqlCommand("SELECT COUNT(*) FROM <your table name>", con)
 
con.Open()
Dim rowCount As Integer = CType(com.ExecuteScalar, Integer)
con.Close()

If you are going to use the data in the DataSet after you check to see if it has rows, then, by all means, fill the DataSet. But, don't just fill a DataSet to check the number of rows and then discard it.

Todd
 
Back
Top