View Single Post
Old July 28th, 2005, 04:58 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

I don't really have an answer to this, but to rule out the reader code (and increase performance) you could use a SELECT COUNT (combined with an output parameter if you're using stored procedure) instead of an entire SELECT.

Right now, you do a full SELECT, only to see if the Reader can read.

Try something like this instead:
Dim cmdResults As SqlClient.SqlCommand
cmdResults = New SqlClient.SqlCommand("SELECT COUNT(*) from SurveyResults where QuestionID=" & v_strQuestionID & " AND UserId='" & strUserID & "' AND SurveyTimeStamp='" & strTimeStamp & "'", m_conResults)

Dim rdrResults As SqlClient.SqlDataReader

  rdrResults = cmdResults.ExecuteReader
  If rdrResults.Read Then
    CanFindSurveyResults  = (mySqlDataReader.GetInt32(0) > 0)

Not sure if it makes a difference, but it at least speeds up the operation by not selecting all the records if you only need a simple count.


Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Moon Over Marin by Dead Kennedys (Track 13 from the album: Plastic Surgery Disasters + In God We Trust) What's This?