Form1 Object Eventargs: Imports Imports Public Class Private Sub Byval As Byval As Handles Mybase Dim As String
Form1 Object Eventargs: Imports Imports Public Class Private Sub Byval As Byval As Handles Mybase Dim As String
OleDb
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim cnString As String
txtStatus.Text = "connecting Ms Access" & vbNewLine
cnString = "Provider=Microsoft.Jet.OleDB.4.0;Persist Security
Info=False;Data Source=" &
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) &
"\nha\data.mdb"
'create command
Dim sqlQRY As String = "Select * from USERINFO where Address='Ktm' "
'create connection
Dim conn As OleDbConnection = New OleDbConnection(cnString)
Try
'create connection
conn.Open()
'oledbcommand
Dim cmd As OleDbCommand = New OleDbCommand(sqlQRY, conn)
'create data reader
Dim rdr As OleDbDataReader = cmd.ExecuteReader
While (rdr.Read)
txtStatus.Text = txtStatus.Text & rdr("Fname").ToString() &
vbNewLine
End While
Catch ex As Exception
txtStatus.Text = "Error:" & ex.ToString & vbNewLine
Finally
conn.Close()
txtStatus.Text = txtStatus.Text & "Connection closed"
End Try
End Sub
End Class
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim cnString As String
txtStatus.Text = "connecting Ms Access" & vbNewLine
cnString = "Provider=Microsoft.Jet.OleDB.4.0;Persist Security
Info=False;Data Source=" &
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) &
"\nha\data.mdb"
'create command
Dim sqlQRY As String = "Select * from USERINFO where Address='Ktm' "
'create connection
Dim conn As OleDbConnection = New OleDbConnection(cnString)
Try
'create connection
conn.Open()
'oledbcommand
Dim cmd As OleDbCommand = New OleDbCommand(sqlQRY, conn)
'create data reader
Dim rdr As OleDbDataReader = cmd.ExecuteReader
While (rdr.Read)
txtStatus.Text = txtStatus.Text & rdr("Fname").ToString() &
vbNewLine
End While
Catch ex As Exception
txtStatus.Text = "Error:" & ex.ToString & vbNewLine
Finally
conn.Close()
txtStatus.Text = txtStatus.Text & "Connection closed"
End Try
End Sub
End Class