calvin Posted December 14, 2006 Posted December 14, 2006 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 Quote
tfowler Posted December 14, 2006 Posted December 14, 2006 The DataSet object still exists: [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: 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.