Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Public Class F_ORDER
Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\MAINDATABASE.mdb"
Dim Conn As OleDbConnection
Dim Comm As OleDbCommand
Public DA As OleDbDataAdapter
Public DT As DataTable
Dim sql As String = ""
Private Sub RunSQL(ByVal sql As String)
Conn = New OleDb.OleDbConnection(connStr)
Comm = New OleDb.OleDbCommand(sql, Conn)
Conn.Open()
Comm.ExecuteNonQuery()
Conn.Close()
End Sub
Private Function SelectSQL(ByVal sql As String) As DataTable
Conn = New OleDbConnection(connStr)
DA = New OleDbDataAdapter(sql, Conn)
DT = New DataTable
DA.Fill(DT)
Return DT
End Function
Private Sub F_ORDER_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BindDataGrid()
End Sub
Private Sub BindDataGrid()
sql = ""
Dim dt As New DataTable
Dim Adapter As SqlCeDataAdapter
myConnection = New SqlCeConnection("Data Source =" + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\Database1.sdf;"))
myConnection = New SqlCeConnection("Data Source=C:\Users\Intel\Desktop\VB\WindowsFormsApplication\WindowsFormsApplication\Database1.sdf;")
myConnection.Open()
Dim myCommand As SqlCeCommand = myConnection.CreateCommand()
myCommand.CommandText = "SELECT [id], [name], [email] FROM [mytable]"
myCommand.CommandType = CommandType.Text
Adapter = New SqlCeDataAdapter(myCommand)
Adapter.Fill(dt)