|
Subject:
|
Using 2 SQL commands
|
|
Posted By:
|
attipa
|
Post Date:
|
9/15/2003 3:42:22 PM
|
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 By:
|
mtuppers
|
Reply Date:
|
9/20/2003 2:55:43 PM
|
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 By:
|
Imar
|
Reply Date:
|
9/20/2003 5:23:09 PM
|
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.
|
|