Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB.NET
|
VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 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 July 5th, 2005, 08:58 AM
Authorized User
 
Join Date: Apr 2005
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to EricJ
Default Trouble with returning parameter values

I have a loop writes data into a sql database which it reads from a datareader.

Once the first record is added, a return value must be specified from the stored procedure in:

        Do While myDataReader.Read

            cmdInsertCurrency.Parameters.Clear() 'Clear the return value for adding of the next available record
            cmdInsertCurrency.Parameters.Add("@RETURN VALUE", DbType.Int32, 0)
            cmdInsertCurrency.Parameters("@RETURN VALUE").Direction = ParameterDirection.ReturnValue
            cmdInsertCurrency.Parameters.Add("@CURRENCY_ID", DBNull.Value)
            cmdInsertCurrency.Parameters.Add("@CURRENCY_CODE", myDataReader.Item(1))
            cmdInsertCurrency.Parameters.Add("@CURRENCY_NAME", myDataReader.Item(2))
            cmdInsertCurrency.Parameters.Add("@START_DATE", #1/1/2000#)
            cmdInsertCurrency.Parameters.Add("@END_DATE", #12/31/9998#)
            cmdInsertCurrency.Parameters.Add("@CHANGE_ID", Decimal.Zero)
            cmdInsertCurrency.Parameters.Add("@SITE_AUDIT_ID", "20120050027000001")
            cmdInsertCurrency.Parameters.Add("@USER_AUDIT_ID", "c242242")
            cmdInsertCurrency.Parameters.Add("@PARENT_AUDIT_ID ", DBNull.Value)

            Try
                myParamAdapter.InsertCommand = cmdInsertCurrency
                cmdInsertCurrency.ExecuteNonQuery()
            Catch ex As Exception
                MsgBox(ex.Message)
                Exit Do
            Finally
                Console.WriteLine(iNumOfRecordsAffected)
            End Try

            iNumOfRecordsAffected += 1

        Loop

It writes my values to the database correctly, but appart from the @RETURN VALUE I specified, I also want to return the value assigned to "@CURRENCY_ID" which is a GUID in my database. Is there any way that I can tell the loop what this value is, as I keep getting a null value returned in the console window.

Can anybody please help me out?






Similar Threads
Thread Thread Starter Forum Replies Last Post
VB2005 trouble returning structure from function MikeCS Visual Basic 2005 Basics 1 November 29th, 2006 07:45 PM
Returning Decimal values from database hasanali00 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 October 10th, 2005 08:10 PM
EXEC function not returning values aingalsbe PHP How-To 0 June 1st, 2004 10:03 AM
Methods - Returning Multiple Values? p_nut33 VB.NET 2002/2003 Basics 5 December 22nd, 2003 10:09 AM
returning values with SQL stu9820 SQL Language 6 December 8th, 2003 02:36 PM





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