Calling a Stored Procedure in an ASP Page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • praveensharmans
    New Member
    • Sep 2007
    • 3

    Calling a Stored Procedure in an ASP Page

    Hi,

    I have created a Stored Procedure Sp_test for Triggering the Mails.

    Can anybody tell me how to Call it inside the function cmdSubmit_oncli ck()

    which is a part of the ASP Script so that I can execute the same.

    Any help will be really appreciated.


    Thanks & Regards,
    Praveen
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Praveen,

    Everything in ASP scripts are executed before the page is sent to the browser. After the browser displays the page and the user begins interacting with it, no more asp procedures can work. The best way to handle this is that on the resulting page where the user visits after clicking the cmdSubmit button the stored procedure is called as the script is executing. I hope this makes sense.

    Jared

    Comment

    • ilearneditonline
      Recognized Expert New Member
      • Jul 2007
      • 130

      #3
      If this is classic ASP, then the solution Jared recommended would be the easiest to implement. If this is ASP.NET, then you just associate the method with the button. If it is vb.net then it would be something like...

      [CODE=vb] Protected Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click
      ' call you stored procedure
      End Sub[/CODE]

      c#
      [code=c]// in the asp.net page
      <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button 1_Click" />

      // in code behind or inline
      protected void Button1_Click(o bject sender, EventArgs e)
      {
      // call stored procedure
      }
      [/code]

      If it is classic asp, and you want to call it without changing pages, you should look at using AJAX and call the stored procedure in a server side page.

      Comment

      Working...