?
Solved

UpdateQuery and Types issue

Posted on 2009-12-16
9
Medium Priority
?
288 Views
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.

Dee
0
Comment
Question by:softspot
  • 4
  • 2
7 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 26069929
where the UpdateQuery coming from? its not SqlDataAdapter method.
0
 

Author Comment

by:softspot
ID: 26071038
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.

D.
0
 

Author Comment

by:softspot
ID: 26274584
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.

Thanks

Softspot.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 26279820
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.
0
 

Author Comment

by:softspot
ID: 26304342
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.

Regards

Softspot
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 26304472
I would use code like below to update a record (SQL Server).



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

Open in new window

0
 

Author Closing Comment

by:softspot
ID: 31667113
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.

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

839 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