Talk2Tom11
Well-known member
Hey, I am trying to read info that I have stored in a ms access file. I have a module and a form. below is the code that I am currently using. It is not reading form the database and I am not sure why... if anyone can take a look at the and tell me what I have done wrong then that would be great... thanks.
Module:
[VB] Public rs As New ADODB.Recordset
Public con As New ADODB.Connection
Public agentController As AgentObjects.Agent
Public agentCharacter As AgentObjects.IAgentCtlCharacter
Sub load_data()
con.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Database.mdb;Persist Security Info=False")
rs.Open("SELECT * FROM Data", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
End Sub[/VB]
Form1:
[VB] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call load_data()
If TextBox1.Text = rs.Fields!Last.Value Then
Label2.Text = rs.Fields!Address.Value
Label3.Text = rs.Fields!Town.Value
Label4.Text = rs.Fields!State.Value
Label5.Text = rs.Fields!Zip.Value
End If
End Sub[/VB]
Module:
[VB] Public rs As New ADODB.Recordset
Public con As New ADODB.Connection
Public agentController As AgentObjects.Agent
Public agentCharacter As AgentObjects.IAgentCtlCharacter
Sub load_data()
con.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\Database.mdb;Persist Security Info=False")
rs.Open("SELECT * FROM Data", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
End Sub[/VB]
Form1:
[VB] Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call load_data()
If TextBox1.Text = rs.Fields!Last.Value Then
Label2.Text = rs.Fields!Address.Value
Label3.Text = rs.Fields!Town.Value
Label4.Text = rs.Fields!State.Value
Label5.Text = rs.Fields!Zip.Value
End If
End Sub[/VB]