Wrox Programmer Forums
|
BOOK: Professional ASP.NET 1.0, Special Edition/1.1
This is the forum to discuss the Wrox book Professional ASP.NET 1.1 by Alex Homer, Dave Sussman, Rob Howard, Brian Francis, Karli Watson, Richard Anderson; ISBN: 9780764558900
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 1.0, Special Edition/1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 8th, 2005, 04:56 AM
Registered User
 
Join Date: Feb 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Executing a SQL Stored Procedure from ASP WEB MATR

I have been reading your book ASP.Net 1.1 with VB.NET 2003. I am having trouble executing stored procedures from the matrix. When I add the statement Imports SqlData.SqlClient at the top of the code page, the statement doesnot seem to fall in place. Message stating that it must come before declaratives. Can you provide some sample code for executing a stored procedure.

 
Old March 25th, 2005, 01:21 PM
Registered User
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

first you should create a storedprocedure
after that,here is some sample:
Code:
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>

<html>
  <head><title>Using Stored Procedures</title></head>
  <body>
    <form runat="server" method="post">
      <asp:DataGrid id="dgOutput" runat="server" />
    </form>
  </body>
</html>

<script language="VB" runat="server">
  Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)

  ' Connection setup
  Dim strConnection As String = ConfigurationSettings.AppSettings("NWind")
  Dim objConnection As New SqlConnection(strConnection)
  Dim objCommand As New SqlCommand( _
                   "[Ten Most Expensive Products]", objConnection)
  objCommand.CommandType = CommandType.StoredProcedure

  objConnection.Open()

  Dim objDataReader As SqlDataReader = objCommand.ExecuteReader()
  dgOutput.DataSource = objDataReader
  dgOutput.DataBind()

  objConnection.Close()
  End Sub
</script>





Similar Threads
Thread Thread Starter Forum Replies Last Post
sql connectivity using stored procedure in asp.net krishna kumari Classic ASP Databases 2 January 17th, 2007 02:45 PM
Executing an UPDATE Stored Procedure ashg657 Access VBA 1 June 9th, 2006 06:29 AM
Create and executing an oracle stored procedure Venstar Oracle 1 January 10th, 2006 05:10 AM
Executing a stored procedure from ASP tlbacon527 Classic ASP Databases 2 January 23rd, 2004 03:50 PM
Executing a Stored Procedure using ASP. treadmill Classic ASP Databases 3 July 24th, 2003 04:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.