Using conn As New OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Northwind.mdb"
conn.Open()
Using cmd As New OleDbCommand()
cmd.CommandText = "[Sales by Category]"
cmd.CommandType = CommandType.StoredProcedure
cmd.Connection = conn
cmd.ExecuteNonQuery()
conn.Close()
End Using
End Using
Dim objConnection As OleDbConnection
Dim objCmd As OleDbCommand
Dim strConnection As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\\temp\\Northwind.mdb"
' Create and open the connection object
objConnection = New OleDbConnection(strConnection)
objConnection.Open()
' Create the Command and set its properties
objCmd = New OleDbCommand()
objCmd.Connection = objConnection
objCmd.CommandText = "[Sales by Category]" ' ชื่อ procedure
'objCmd.Parameters.Add(New OleDbParameter("@param", "xxx")) 'กรณีที่มี parameter (รับตัวแปร)
objCmd.CommandType = CommandType.StoredProcedure
Dim adapter As New OleDbDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
adapter.SelectCommand = objCmd
adapter.Fill(ds)
dt = ds.Tables(0)
If (dt.Rows.Count > 0) Then
For index = 0 To dt.Rows.Count - 1
Console.WriteLine(dt.Rows(index)(0))
Next
'Gridview.DataSource = dt
End If
Console.ReadLine()