Solved

Cant add paramenter to data adapter

Posted on 2014-03-19
3
128 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
Comment Utility
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 74

Expert Comment

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

Author Closing Comment

by:mgmhicks
Comment Utility
thank you
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now