How can I find a specific record from a MS-Access database in VB.NET? I am using an ADO connection.
I would attach my existing code but can't figure out how.
Anyone can email me at [email protected] and I will send the code along to them for review.
Satyapriya NayakPosted Dec 2, 2012, 10:59 AM
Form1.vb
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim ConnectionString As String = System.Configuration.ConfigurationSettings.AppSettings("dsn")
Dim con As OleDbConnection = New OleDbConnection(ConnectionString)
Dim com As OleDbCommand
Dim oledbda As OleDbDataAdapter
Dim ds As DataSet
Dim str As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
con.Open()
str = "select * from employee"
com = New OleDbCommand(str, con)
oledbda = New OleDbDataAdapter(com)
ds = New DataSet
oledbda.Fill(ds, "employee")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "employee"
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class