Wrox Programmer Forums
|
BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1
This is the forum to discuss the Wrox book Professional Visual Basic 2008 by Bill Evjen, Billy Hollis, Bill Sheldon, Kent Sharkey; ISBN: 9780470191361
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1 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 August 12th, 2010, 03:58 PM
Registered User
 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default BuildSqlCommand

I tried to use the add parameters routine described in chapter 9 page 346
my example is below. The program returns indicating my first parameter is missing, although the parameter count is correct. Is the second parameter overwriting?

Code:
        Dim cmd As SqlCommand = New SqlCommand(uspGroupXref, connSql)
        cmd.CommandType = CommandType.StoredProcedure
        Dim parameter As SqlParameter = Nothing
        parameter = New SqlParameter
        parameter.ParameterName = "@sBCAPartner"
        parameter.SourceColumn = sBCAPartner
        cmd.Parameters.Add(parameter)
        parameter = New SqlParameter
        parameter.ParameterName = "@sLabAcctNbr"
        parameter.SourceColumn = sLabAcctNbr
        cmd.Parameters.Add(parameter)
        cmd.Connection.Open()
        Dim myreader As SqlDataReader

        Dim returndata As String = ""
        myreader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
 
Old August 18th, 2010, 02:14 PM
Registered User
 
Join Date: Jul 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Saw what I did wrong. I wanted to do an Add(new sqlparameter ..) and not a new sqlparameter.









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