Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Public con As New OleDbConnection
Public Sub connectData() Handles MyBase.Load
Dim s As String
If con.State = ConnectionState.Open Then con.Close()
s = "Provider = Microsoft.Jet.OLEDB.4.0;"
s = s + "Data Source =C:Data1.mdb;"///อันนี้ก็อปพาร์ทมาใส่เลย
s = s + "User Id=;Password=;"
con.ConnectionString = s
con.Open()
End Sub
Public Sub FormLoad() Handles MyBase.Load
connectData()
MessageBox.Show("เชื่อมต่อฐานข้อมูลสำเร็จ", "welcome")
End Sub
Public Function ExecuteReader(ByVal prmSQL As String) As OleDbDataReader
Dim dr As OleDbDataReader
Dim com As New OleDbCommand
connectData()
com.CommandType = CommandType.Text
com.CommandText = prmSQL
com.Connection = con
dr = com.ExecuteReader
Return dr
End Function