sde Posted November 3, 2003 Posted November 3, 2003 what is the best way to return the total number of rows found in a query to SQL2k ? i can connect and query, .. i'm just wondering the most efficient way to see if a user/pass row exists. Quote codenewbie
sde Posted November 3, 2003 Author Posted November 3, 2003 i guess i should be more specific. right now i'm creating a data adapter.. and filling a dataset. then i use rows.count on the data table in the dataset. that seems like a lot of things to do just to get the number of rows found. Quote codenewbie
Administrators PlausiblyDamp Posted November 3, 2003 Administrators Posted November 3, 2003 If the DB is SQL you could just return the @@rowcount. Or alternatively "SELECT COUNT(*) FROM WHERE Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Volte Posted November 3, 2003 *Experts* Posted November 3, 2003 You need to set an alias for the COUNT.SELECT COUNT(id) AS rowcount FROM mytable WHERE id = 7Then use 'rowcount' as if it was a regular field. Quote
sde Posted November 3, 2003 Author Posted November 3, 2003 is DataReader object will be the quickest way of reading this field then? thanks for the time. Quote codenewbie
*Experts* Volte Posted November 3, 2003 *Experts* Posted November 3, 2003 I would say it most likely is the quickest. Quote
Administrators PlausiblyDamp Posted November 4, 2003 Administrators Posted November 4, 2003 How about Command.ExecuteScalar ? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Volte Posted November 4, 2003 *Experts* Posted November 4, 2003 Ah, I didn't think of that. Indeed that would be the quickest. 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.