Dim conn As New OleDbConnection Dim sConnString As String Dim cmd As New OleDbCommand Dim da As New OleDbDataAdapter Dim dt As New DataTable Try If Microsoft.VisualBasic.Right(Application.StartupPath, 1) = "\" Then sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "trial.mdb;Persist Security Info=False;" Else sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\trial.mdb;Persist Security Info=False;" End If conn = New OleDbConnection(sConnString) conn.Open() cmd.Connection = conn cmd.CommandType = CommandType.Text cmd.CommandText = "select id,firstname ,lastname,address,mobile from Client" da.SelectCommand = cmd da.Fill(dt) Me.DataGridView1.DataSource = dt Catch ex As Exception MsgBox(ErrorToString) Finally conn.Close() End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)