Im new to trying to use ADO.NET but have had alot of previous experience with standard ADO.
How do you get a recordcount for a dataset?
This is what i am doing now.. but I know there has to be a better way.
Code:Private Function MaxRecords() As Integer Dim sqlSelect As String sqlSelect = "Select [Question] From [tblQuestions]" Dim con As New OleDbConnection(ConnectionString) Dim cmd As New OleDbCommand(sqlSelect, con) Dim reader As OleDbDataReader Try con.Open() reader = cmd.ExecuteReader() MaxRecords = 0 Do While reader.Read() MaxRecords = MaxRecords + 1 Loop reader.Close() Catch err As Exception lblQuestion.Text = "Error reading survey data. " lblQuestion.Text &= err.Message & " " Finally If (Not con Is Nothing) Then con.Close() End If End Try End Function




Reply With Quote