Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 September 15th, 2003, 03:42 PM
Authorized User
 
Join Date: Jun 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using 2 SQL commands

Hello,

I am trying to get 2 commands work at the same time. Below, I have included the code and the stored procedure. The portion of the code that has been commented out is the part I want to have working. what lines of code can be added to the one i have already shown to make this work. i need to have this portion of the project working soon. thanks in advance.

Code
-------------
Friend ReadOnly Property CurrentOrderDetails() As OrderDetails
Get
If _currentOrderDetails Is Nothing Then
Dim command As SqlCommand = New SqlCommand("GetOrderDetails", Connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@OrderID", OrderID)
'Dim command2 As SqlCommand = New SqlCommand("GetFinalValuesByOrderID", Connection)
'command2.CommandType = CommandType.StoredProcedure
'command2.Parameters.Add("@OrderID", OrderID)
Dim reader As SqlDataReader = command.ExecuteReader()
'CartTotal = command2.Parameters("@CartTotal" ).Value.ToString
'CartTax = command2.Parameters("@CartTax" ).Value.ToString
'CartShipping = command2.Parameters("@CartShipping" ).Value.ToString
'CartDiscount = command2.Parameters("@CartDiscount" ).Value.ToString

Try
_currentOrderDetails = New OrderDetails(reader, CartDiscount, CartTax, CartShipping, CartTotal, ShippingOption, Frequency, CartDiscountCode)
Catch
Throw
Finally
reader.Close()
End Try
End If
Return _currentOrderDetails
End Get
End Property
---------------

Stored Procedure
-----------------
CREATE PROCEDURE GetFinalValuesByOrderID
(@OrderID int,
@CartTotal money OUTPUT,
@CartTax money OUTPUT,
@CartShipping money OUTPUT,
@CartDiscount money OUTPUT)
AS
Select @CartDiscount = CartDiscount, @CartTax = CartTax, @CartShipping = CartShipping, @CartTotal = CartTotal
From Orders
Where OrderID = @OrderID
RETURN
GO
-----------------
 
Old September 20th, 2003, 02:55 PM
Authorized User
 
Join Date: Sep 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, try catch is in javascript, as document in windows Script.

I think you should using Do ... until string = what.

Go to google.com or msdn.microsoft.com and search for windows script

 
Old September 20th, 2003, 05:23 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

This is an ASP forum, so you may try your luck on one of the .NET forums for questions like this.

Anyway, the problem you have (at least that's what I think, as you didn't explain the problem at all) is that you can't have a DataReader and other actions on the same connection. That is, as soon as you open the DataReader (command.ExecuteReader()), you can't use the connection until you call the Close method of the reader. There are two ways around this: either create a second Connection object and use that for the second command object, or change your coding logic so it requires only one active command object with an open connection at a time.

P.S. mtuppers, Try / Catch is also C#, VB.NET and some other programming languages. So this wasn't about Windows Script, but about VB.NET.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
sql commands dr BOOK: Beginning Ruby on Rails 1 April 27th, 2007 12:22 PM
using sql commands C# N4th SQL Server 2000 0 December 15th, 2006 02:04 PM
runtime sqldatasource sql commands- HELP iori ASP.NET 2.0 Basics 0 August 14th, 2006 05:38 PM
How to exeucte a file containing sql commands Hari_Word VB How-To 2 September 30th, 2004 06:00 AM
Dynamically Changing SQL Commands? avantjer BOOK: Professional Crystal Reports for VS.NET 2 May 18th, 2004 11:29 PM





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