CSharp Call Store Procedure Through Sqlconnection – ADO.Net Database

<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">    Sub Page_Load(Sender As Object, E As EventArgs)
        Dim ConnectionString As String = _
              "server=(local)\netsdk;database=cam;trusted_connection=true"
 
        Dim CommandText As String = "AllDiscsByDate"
 
        Dim myConnection As New SqlConnection(ConnectionString)
        Dim myCommand As New SqlCommand(CommandText, myConnection)
        Dim workParam As New SqlParameter()
 
        myCommand.CommandType = CommandType.StoredProcedure
 
        myConnection.Open()
 
        DataGrid1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
        DataGrid1.DataBind()
 
    End Sub</script>
<html>
<head>
</head>
<body>
    <h2>Simple Stored Procedure </h2>
    <form runat="server">
        <asp:datagrid id="DataGrid1" runat="server" CellSpacing="1" GridLines="None" CellPadding="3" BackColor="White" ForeColor="Black" EnableViewState="False">
            <headerStyle font-bold="True" forecolor="white" backcolor="#4A3C8C"></headerStyle>
            <itemStyle backcolor="#DEDFDE"></itemStyle>
        </asp:datagrid>
    </form>
</body>
</html>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.