Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 15th, 2003, 03:42 PM
Authorized User
 
Join Date: Jun 2003
Location: , , .
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
-----------------
Reply With Quote
  #2 (permalink)  
Old September 20th, 2003, 02:55 PM
Authorized User
 
Join Date: Sep 2003
Location: , , .
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

Reply With Quote
  #3 (permalink)  
Old September 20th, 2003, 05:23 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.