Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 March 19th, 2006, 01:11 PM
Authorized User
Join Date: Jul 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Querying the NorthWind Database

Hello and thank you for taking a moment to read this message. I am new to ASP.NET and am trying to write a search page that queries the Northwind Database. When I go to run my application, I hit the submit button( this would run my query) I get error below. Also below is my code-behind for the application. If anybody has any suggestions, I would be extremely grateful. Thank you- Jason

Line 1: Incorrect syntax near 'usp_Find_Orders'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near 'usp_Find_Orders'.

Source Error:

Line 43:
Line 44: objConn.Open()
Line 45: dgrdOrders.DataSource = objCommand.ExecuteReader()
Line 46: dgrdOrders.DataBind()
Line 47: objConn.Close()
Source File: C:\Documents and Settings\Jason Livengood\My Documents\Visual Studio 2005\WebSites\WebSite3\Default.aspx.vb Line: 45

---------------------------------------------------------------------Partial Class _Default

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Sub Submit(ByVal Source As Object, ByVal E As EventArgs) Handles btnSearch.Click

If txtOrderNumber.Text Is DBNull.Value Then

txtOrderNumber.Text = "10248"

End If

If txtProductName.Text Is DBNull.Value Then

txtProductName.Text = "Queso Cabrales"

End If

If txtShippedDate.Text Is DBNull.Value Then

txtShippedDate.Text = "7/16/1996"

End If

If txtpersonshippedto.Text Is DBNull.Value Then

txtpersonshippedto.Text = "Vins et alcools Chevalier"

End If

Dim strConn As String = ConfigurationManager.AppSettings("NWind")

Dim objConn As New Data.SqlClient.SqlConnection(strConn)

Dim objCommand As New Data.SqlClient.SqlCommand("usp_Find_Orders", objConn)

objCommand.Parameters.AddWithValue("@OrderID", txtOrderNumber.Text)

objCommand.Parameters.AddWithValue("@ProductName", txtProductName.Text)

objCommand.Parameters.AddWithValue("@ShippedDate", txtShippedDate.Text)

objCommand.Parameters.AddWithValue("@ShipName", txtpersonshippedto.Text)


dgrdOrders.DataSource = objCommand.ExecuteReader()



End Sub

End Class

Old March 19th, 2006, 04:36 PM
Friend of Wrox
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts

Try adding:
objCommand.CommandType = CommandType.StoredProcedure

Similar Threads
Thread Thread Starter Forum Replies Last Post
northwind database terkilsen BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 2 April 3rd, 2006 08:55 AM
Northwind database iem BOOK: Professional Crystal Reports for VS.NET 8 August 1st, 2004 11:30 PM

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