Replacing ObjectList with Text Boxes When Using Database

John-Boy1

Member
Joined
Mar 6, 2006
Messages
14
Programming Experience
Beginner
I have created a ASP programme which allows you to load a list of CDs from an Access database displaying in an ObjectList.
____________________________________________________________________________
Private Sub DataLoad()
Try
Dim myConnection As New OleDbConnection(myConnectionString)
Dim myCommand As New OleDbCommand("Select * from CDList", myConnection)
Dim myDataAdapter As New OleDbDataAdapter(myCommand)
myConnection.Open()
myDataAdapter.Fill(myDataSet, "CDList")
ObjectList1.AutoGenerateFields = True
ObjectList1.DataSource = myDataSet
ObjectList1.DataBind()
myConnection.Close()
Catch ex As Exception
Label1.Text = "Error reading database " & ex.Message
End Try
End Sub
____________________________________________________________________________
Instead of using an ObjectList I want to display each column of the database in individual text boxes i.e. Title, Artist, Tracks, RunningTime and ID. And then allow the user to move from record to record viewing the data.
Im really stuck on this and been struggling for ages. Any tutorials or help will be much appreciated.
 
I think the simple solution is to bind the textboxs to the fields of the dataTable.

something like:
Me.txtTitle.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.myDataSet, "CDList.Title"))
Me.txtArtist.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.myDataSet, "CDList.Artist"))

Moving through the dataset can be done many ways:
Me.BindingContext(myDataSet, "CDList").Position += 1 'Move foward 1
Me.BindingContext(myDataSet, "CDList").Position -= 1 'Move back 1
Me.BindingContext(myDataSet, "CDList").Position = 0 'Move to first record
Me.BindingContext(myDataSet, "CDList").Position = Me.BindingContext(myDataSet, "CDList").count -1 'Move to last record
 
Back
Top