[2005] My database information is not displayed at my label
When the user selects the combobox type, the information will display at the label like this.
http://i31.photobucket.com/albums/c377/Angelicia/vb.jpg
However, when I run it, it display like this.
http://i31.photobucket.com/albums/c3...elicia/vb2.jpg
By right, the labels i created should display with the information in the database. I have check my database and all the values are there. Who can help me solve whats wrong with it and what should I do?
Here are the codes:
VB Code:
Public Class fine
Private Sub fine_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =C:\temp\db1.mdb"
Dim con As OleDb.OleDbConnection
Dim dr As OleDb.OleDbDataReader
Dim cmd As New OleDb.OleDbCommand
Try
Dim strselect As String = "Select * from fine where BorrowerId = '" & Form1.tbxID.Text & "'"
'create a new connection
con = New OleDb.OleDbConnection(strcon)
con.Open()
cmd.Connection = con
cmd.CommandText = strselect
dr = cmd.ExecuteReader
If dr.Read Then
tbxname.Text = dr("memberName")
tbxadmin.Text = dr("BorrowerId")
End If
dr.Close()
dr.Close()
Catch eException As Exception
MessageBox.Show(eException.Message)
End Try
End Sub
Private Sub cbxtype_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbxtype.SelectedIndexChanged
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =C:\temp\db1.mdb"
Dim con As OleDb.OleDbConnection
Dim dr As OleDb.OleDbDataReader
Dim cmd As New OleDb.OleDbCommand
Try
Dim strselect As String = "Select * from fine where fineType = '" & cbxtype.Text & "' And BorrowerId = '" & Form1.tbxID.Text & "'"
'create a new connection
con = New OleDb.OleDbConnection(strcon)
con.Open()
cmd.Connection = con
cmd.CommandText = strselect
dr = cmd.ExecuteReader
If dr.Read Then
lblID.Text = dr("fineId")
lblitem.Text = dr("itemId")
lbltitle.Text = dr("itemTitle")
lbldue.Text = dr("dueDate")
lblreturn.Text = dr("dateReturn")
lbloverdue.Text = dr("daysOverdue")
End If
dr.Close()
dr.Close()
Catch eException As Exception
MessageBox.Show(eException.Message)
End Try
End Sub
End Class