CSharp Retrieving Data From Stored Procedure – ADO.Net Database

<%--
ASP.NET Tips & Techniques (Paperback)
by Greg Buczek Publisher: McGraw-Hill/Osborne Media; 1st edition (May 21, 2002)
Language: English
ISBN: 0072225149
--%>
 
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim DBConn as SQLConnection
    Dim DBCommand As SQLDataAdapter
    Dim DSPageData as New DataSet
    DBConn = New SQLConnection("server=localhost;" _
        & "Initial Catalog=TT;" _
        & "User Id=sa;" _
        & "Password=yourpassword;")
    DBCommand = New SQLDataAdapter _
        ("Exec CurrentMonthBirthDays", DBConn)
    DBCommand.Fill(DSPageData, _
        "Emps")
    dgEmps.DataSource = _
        DSPageData.Tables("Emps").DefaultView
    dgEmps.DataBind()
End Sub
</script>
<html>
<head>
<title>Retrieving Data from a Stored Procedure</title>
</head>
<body LEFTMARGIN="40">
<form runat="server">
<br /><br />
<asp:datagrid
    id="dgEmps"
    runat="server"
    autogeneratecolumns="True"
>
</asp:datagrid>
</form>
</body>
</html>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.