Having found the following post on datareaders Topic Posted On DaniWeb i have managed to successfully create a datareader in a class that updates a listbox on the calling form with entries retrieved from a SQL server database.

I was wondering if it is possible to achieve the same thing using a dataset?

My ultimate aim is to read a SQL table / view of information (ie customers), add this into a list box so that when i click on a specifc line in the list box i can then use that selected entry to do something further (ie click a line and then an edit button to edit that records details)

Here is the code im using for the data reader, any suggestions would be gratefully recieved.

Public Sub ReadCampaignRecords(ByVal strSQLServerConnectionString As String, ByVal strSqlCommandString As String)
        Dim objSqlConnection As New SqlConnection(strSQLServerConnectionString)
        Dim strSqlCommand As New SqlCommand(strSqlCommandString, objSqlConnection)

        If IsNothing(strSQLServerConnectionString) Then
            MessageBox.Show("Connection String Not Set")
        ElseIf IsNothing(strSqlCommandString) Then
            MessageBox.Show("No SQL Command Set")

                Dim objDataReader As SqlDataReader = strSqlCommand.ExecuteReader()
                Dim strDataToView As String

                While objDataReader.Read()
                    Dim Number As Integer = CInt(objDataReader("Number"))
                    Dim StartDate As Date = CDate(objDataReader("StartDate"))
                    Dim EndDate As Date = CDate(objDataReader("EndDate"))

                    strDataToView = "Campaign  " & Number & "     Running From  = " & StartDate & " To " & EndDate

                End While

            Catch ex As Exception

                Exit Sub
            End Try
        End If
    End Sub
End Class

Edited by OldManStarting: n/a

6 Years
Discussion Span
Last Post by OldManStarting
Featured Replies
  • 1

    [URL="http://vb.net-informations.com/dataset/vb.net-ado.net-dataset-tutorial.htm"]http://vb.net-informations.com/dataset/vb.net-ado.net-dataset-tutorial.htm[/URL] This link may be helpful. Read More


Thanks Ranx.

That looks like it might be what im after, ill have a more detailed look later and post if it solves the issue.


Just a quick update, that page was exactly what i needed, i had previously created a dataset but could not work out the full commands to retrieve each row of data.

Thanks for the help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.