Reply to topic
MS Access stored procedure example
Geof


Joined: 06 Apr 2005
Posts: 4
Reply with quote
Access stored procedures are desirable because you know they work and you don't have to mess around with building the SQL string in the codebehind file. Here's a VB example of filling a datagrid called dgMT.

Code:
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Public Class Class1
    Inherits Page

Protected WithEvents dgMT As System.Web.UI.WebControls.DataGrid

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
   
Dim objConnect As New OleDbConnection("PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & HttpContext.Current.Server.MapPath("\db\xyz.mdb"))
Dim cmdTherapists As OleDbCommand
Dim objDataReader As OleDbDataReader

cmdTherapists = New OleDbCommand

        With cmdTherapists
            .Connection = objConnect
            .CommandType = CommandType.StoredProcedure
            .CommandText = "QSEL_ABC"
            .Connection.Open()
            objDataReader = .ExecuteReader()
            Me.dgMT.DataSource = objDataReader
            Me.dgMT.DataBind()
            .Connection.Close()
        End With

    End Sub

End Class
MS Access stored procedure example
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic