ADO DOT NET Posted March 13, 2007 Posted March 13, 2007 Dim ReadUsers As New OleDb.OleDbCommand("SELECT Email, FirstName, LastName FROM Users WHERE GroupID = '" + MyID + "'", MyConnection) Dim MyReaders As OleDbDataReader = ReadUsers.ExecuteReader While MyReaders.Read MsgBox (MyReaders("Email").ToString) End While Hi, The above code works fine, just I have 1 question: When I SELECT Email FROM USERS WHERE GroupID = blah How can I detect that how many fields have been selected?! Thanks:) Quote
Administrators PlausiblyDamp Posted March 13, 2007 Administrators Posted March 13, 2007 [highlight=sql] SELECT COUNT(*) FROM Users WHERE GroupID = '" + MyID + "'" [/highlight] Although I would avoid string concatenation and use a parametrised query or a stored proc instead. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ADO DOT NET Posted March 14, 2007 Author Posted March 14, 2007 [highlight=sql] SELECT COUNT(*) FROM Users WHERE GroupID = '" + MyID + "'" [/highlight] Although I would avoid string concatenation and use a parametrised query or a stored proc instead. You completely misunderstood! I mean when I use: SELECT Email, FirstName, LastName FROM Users WHERE GroupID = ... Then I want to know the number of fields that match this select term and have been selected? Or there are how many fields that their GroupID = equals = MyID? Quote
Administrators PlausiblyDamp Posted March 14, 2007 Administrators Posted March 14, 2007 MyReaders.FieldCount Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
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.