Solved

Cant add paramenter to data adapter

Posted on 2014-03-19
3
138 Views
Last Modified: 2014-03-19
I have a data adapter I am trying to associate parameters to so I can run an da.update(ds) statement.  Here is my code.

 
Dim myCMD As New SqlCommand
        myCMD.Connection = myConn
        myCMD.CommandText = "TAG_UpdateSQFT"
        myCMD.CommandType = CommandType.StoredProcedure
        Dim param1 As New SqlParameter("@SQFT", SqlDbType.NVarChar, 10, "SQFT")
        Dim param2 As New SqlParameter("@ID", SqlDbType.Int, 10, "ID")
        myDA.UpdateCommand.Parameters.Add(New SqlParameter(param1))
        myDA.UpdateCommand.Parameters.Add(param2)
        myDA.UpdateCommand = myCMD

Open in new window


Keeps dealing me I need the new keyword.  Could someone help me out.

thanks in advance.
0
Comment
Question by:mgmhicks
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39939890
You need to switch these lines:
        myDA.UpdateCommand.Parameters.Add(New SqlParameter(param1))
        myDA.UpdateCommand.Parameters.Add(param2)
        myDA.UpdateCommand = myCMD

Open in new window

To:
        myDA.UpdateCommand = myCMD
        myDA.UpdateCommand.Parameters.Add(New SqlParameter(param1))
        myDA.UpdateCommand.Parameters.Add(param2)

Open in new window

As you need to assign a command object to the UpdateCommand before you can start altering it.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39939908
Or change the "myDA.UpdateCommand" in lines 7 and 8 to "myCMD".
0
 

Author Closing Comment

by:mgmhicks
ID: 39940650
thank you
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question