CSharp Call Store Procedure – ADO.Net Database

<%@ 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 DBSP As New SQLCommand
    DBConn = New SQLConnection("server=yourhost;" _
        & "Initial Catalog=TT;" _
        & "User Id=sa;" _
        & "Password=yourpassword;")
    DBSP.CommandText = "Exec AddGarbageRecord"
    DBSP.Connection = DBConn
    DBSP.Connection.Open
    DBSP.ExecuteNonQuery()
    lblMessage.Text = "Stored procedure completed."
End Sub
</script>
<html>
<head>
<title>Calling a Stored Procedure</title>
</head>
<body LEFTMARGIN="40">
<form runat="server">
<br /><br />
<asp:label
    id="lblMessage"
    runat="Server"
/>
</form>
</body>
</html>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.