Call store procedure through OleDbConnection (VB.net) : Store Procedure OleDbConnection « ADO.net Database « ASP.Net






Call store procedure through OleDbConnection (VB.net)

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script language="VB" runat="server">

  Sub Page_Load(Sender As Object, E As EventArgs)

    Dim objConnection As OleDbConnection
    Dim objCmd        As OleDbCommand
    Dim strConnection As String
    
    strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                    "Data Source=C:\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]"
    objCmd.CommandType = CommandType.StoredProcedure

    dgSales.DataSource = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
    dgSales.DataBind()

  End Sub

</script>

<html>
  <body>
    <h2>Using a stored procedure</h2>
    <asp:datagrid id="dgSales" runat="server" />
  </body>
</html>

           
       








Northwind.zip( 736 k)

Related examples in the same category

1.Call stored procedure in access database (VB.net)
2.Call store procedure (VB.net)
3.Call store procedure through OldDbconnection in C#