Hello,
I do the simple project using VB.net 2008 to link with MS Access 2007. I have two textbox which is data for ID and Fullname.
txtID.Text = ID
txtFullname.Text = Fullname
Button1 = Search
In MS Access
My data for ID : 1,2 & 3
and My data for Fullname : John, Peter & Mike
The problem I facing now is when I type '1' in txtID, output was appear in txtFullname. But when I type '2' in txtID, the output is not appear in txtFullname.
Only ID 1 I can call. BUt another ID can't.
PLease Help me.
This is my code :
Imports System.Data.OleDb
Public Class Form1
Dim con As New OleDbConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\sample.accdb"
con.Open()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("SELECT * FROM phonebookTable", con)
da.Fill(dt)
txtID.Text = dt.Rows(0).Item(0)
txtFullname.Text = dt.Rows(1).Item(0)
con.Close()
End Sub
End Class