UpdateQuery and Types issue

Posted on 2009-12-16
Last Modified: 2013-11-08
I am trying to use the UpdateQuery Method to update the Customer Table in a Dataset (CustDatabaseDataset) and taking the second parameter from a TextBox. (Complete) The code is as follows:

 Me.CustomersTableAdapter.UpdateQuery(Me.CustDatabaseDataSet.Customers, Complete.Text)
I get an error:which highlights 'Me.CustDatabaseDataSet.Customers' and says 'value of type 'SalesRep.CustDatabaseDataSet.CustomersDatatable' cannot be converted to an integer.'

The update query works if a create a stand-alone SQL update.. I am not at all experienced with VStudio Database manipulation. Any hints would be appreciated.

Question by:softspot
    LVL 42

    Expert Comment

    where the UpdateQuery coming from? its not SqlDataAdapter method.

    Author Comment

    I have this in some notes. The format of the method was UpdateQuery(X,Y) where X is the data record to be updated and y is the new data. From what you say it looks like it does not exist in this context. I thought it was too easy to be true.I am actually proposing to build a mobile application and I want to update a Compact Framework 3.5 (sdf) database which will be deployed with the app. It seems straightforward really. The user enters the input data and an update method is called to update a record?. I'll go read more.


    Author Comment

    I would like to keep this issue alive because it seems that it should be possible to update a database entry with data entered via a textbox (Visual Studio), This may not be sedgewick's area but maybe someone can helo. Microsoft's help is good on 'what you can do', but not so good on how to do it. I don't expect a tutorial, but a pointer to where I might find a solution to this would be much appreciated.


    LVL 83

    Expert Comment

    The update method works when supplied a modified dataset. The dataset, when bound to some controls such as a grid or textboxes, contains both old and modified values. Your approach wont work. There are two options for you. One is to use the dataadapter already created (which i dont prefer). The other method is to use a connection and command object to manually update the record(this one is especially useful when updating only one record). Let me know which path you want to follow and i will provide the code and further details.

    Author Comment

    Thanks for this. If I am beginning to understand this, the connection and command Object would seem to offer a more flexible solution. I'd be keen to read your views on coding this.


    LVL 83

    Accepted Solution

    I would use code like below to update a record (SQL Server).

    Dim dbcon as new SQLConnection(connectionstring)
    Dim dbcmd as new SQLCommand
    dbcmd.Connection = dbcon
    dbcmd.CommandText = "Update tablename Set columnname=value ... Where columnname = value"

    Open in new window


    Author Closing Comment

    Thanks for this. Even though the original problem is simple in principle, it is very difficult to find practical solutions. This is a great help.


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

    755 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

    17 Experts available now in Live!

    Get 1:1 Help Now