473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

data adapter update fails

I'm getting an inconsistent failure when trying to save
data in ADO.Net.

I'm using an Access database with a simple query - SELECT
StudentID, FirstName, LastName FROM Students - and have
no other users in the database. I keep getting the
message 'Operation must use an updateable query.'

Process seems to work on some PC's, not others. Is there
a difference in .Net framework versions? Or some other
place to look for the problem? I'm using a datatable, and
dataadapter with command builder, using disconnected
data. Help!
Nov 20 '05 #1
8 1886
Here is an example of an update query I did with an access DB. Compare with
Yours.

Regards - OHM

'setup People Update Command

peopleUpdateCmd.CommandText = "UPDATE People SET Address1 = ?, Address2 = ?,
Address3 = ?, Address4 = ?, Country" & _

" = ?, County = ?, DOB = ?, Email = ?, FirstName = ?, [Home Phone] = ?,
LastName " & _

"= ?, MiddleInnitial = ?, [Mobile Fone] = ?, [Post Code] = ?, Town = ? WHERE
(ID " & _

"= ?) AND (Address1 = ?) AND (Address2 = ?) AND (Address3 = ?) AND (Address4
= ?)" & _

" AND (Country = ?) AND (County = ?) AND (DOB = ?) AND (Email = ? OR ? IS
NULL AN" & _

"D Email IS NULL) AND (FirstName = ?) AND ([Home Phone] = ?) AND (LastName =
?) A" & _

"ND (MiddleInnitial = ? OR ? IS NULL AND MiddleInnitial IS NULL) AND
([Mobile Fon" & _

"e] = ? OR ? IS NULL AND [Mobile Fone] IS NULL) AND ([Post Code] = ?) AND
(Town =" & _

" ?)"





Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
"rriness" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I'm getting an inconsistent failure when trying to save
data in ADO.Net.

I'm using an Access database with a simple query - SELECT
StudentID, FirstName, LastName FROM Students - and have
no other users in the database. I keep getting the
message 'Operation must use an updateable query.'

Process seems to work on some PC's, not others. Is there
a difference in .Net framework versions? Or some other
place to look for the problem? I'm using a datatable, and
dataadapter with command builder, using disconnected
data. Help!

Nov 20 '05 #2
I was hoping not to have to build my own command - the
select statement meets the requirements of a single
table, with a one field primary key....

In your query how do you map the ? (parameters) to
fields/alternate values? (Each field has an original
value, a current value if changed since the data was
read). Thanks for your help.
-----Original Message-----
Here is an example of an update query I did with an access DB. Compare withYours.

Regards - OHM

'setup People Update Command

peopleUpdateCmd.CommandText = "UPDATE People SET Address1 = ?, Address2 = ?,Address3 = ?, Address4 = ?, Country" & _

" = ?, County = ?, DOB = ?, Email = ?, FirstName = ?, [Home Phone] = ?,LastName " & _

"= ?, MiddleInnitial = ?, [Mobile Fone] = ?, [Post Code] = ?, Town = ? WHERE(ID " & _

"= ?) AND (Address1 = ?) AND (Address2 = ?) AND (Address3 = ?) AND (Address4= ?)" & _

" AND (Country = ?) AND (County = ?) AND (DOB = ?) AND (Email = ? OR ? ISNULL AN" & _

"D Email IS NULL) AND (FirstName = ?) AND ([Home Phone] = ?) AND (LastName =?) A" & _

"ND (MiddleInnitial = ? OR ? IS NULL AND MiddleInnitial IS NULL) AND([Mobile Fon" & _

"e] = ? OR ? IS NULL AND [Mobile Fone] IS NULL) AND ([Post Code] = ?) AND(Town =" & _

" ?)"





Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com"rriness" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
I'm getting an inconsistent failure when trying to save
data in ADO.Net.

I'm using an Access database with a simple query - SELECT StudentID, FirstName, LastName FROM Students - and have
no other users in the database. I keep getting the
message 'Operation must use an updateable query.'

Process seems to work on some PC's, not others. Is there a difference in .Net framework versions? Or some other
place to look for the problem? I'm using a datatable, and dataadapter with command builder, using disconnected
data. Help!

.

Nov 20 '05 #3
Hi,

If the query includes all of the columns in the table you might try using a
commandbuilder. You simply have to dim it to have it develop the necessary
update commands dynamically.

HTH,

Bernie Yaeger

"rriness" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I'm getting an inconsistent failure when trying to save
data in ADO.Net.

I'm using an Access database with a simple query - SELECT
StudentID, FirstName, LastName FROM Students - and have
no other users in the database. I keep getting the
message 'Operation must use an updateable query.'

Process seems to work on some PC's, not others. Is there
a difference in .Net framework versions? Or some other
place to look for the problem? I'm using a datatable, and
dataadapter with command builder, using disconnected
data. Help!

Nov 20 '05 #4
Cor
Hi rriness,

Process seems to work on some PC's, not others. Is there
a difference in .Net framework versions?


Yes

But you can load both on one computer

I hope this helps a little bit?

Cor
Nov 20 '05 #5
Its an alternative, the only problem is that Command Builder cannot handle
complex SQL statements and when joins are used it cant handle those either.

Regards - OHM

Bernie Yaeger wrote:
Hi,

If the query includes all of the columns in the table you might try
using a commandbuilder. You simply have to dim it to have it develop
the necessary update commands dynamically.

HTH,

Bernie Yaeger

"rriness" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I'm getting an inconsistent failure when trying to save
data in ADO.Net.

I'm using an Access database with a simple query - SELECT
StudentID, FirstName, LastName FROM Students - and have
no other users in the database. I keep getting the
message 'Operation must use an updateable query.'

Process seems to work on some PC's, not others. Is there
a difference in .Net framework versions? Or some other
place to look for the problem? I'm using a datatable, and
dataadapter with command builder, using disconnected
data. Help!


Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
Nov 20 '05 #6
Hello,

As bernie points out , you can use the CommandBuilder class. However, it has
limitations, if you SQL queries are simple, then it may suit you to do this.

As far as the parameters are concerned, the ? characters are placeholders as
connecting with OLEDB you cannot have named parameters as you do in SQL, so
the Parameters have to be read in the order of the SQL statement and the ?
means an unknown value being returned.( Thats why its a question mark ).

Try the builder, you can find references in the help.

Regards - OHM
rriness wrote:
I was hoping not to have to build my own command - the
select statement meets the requirements of a single
table, with a one field primary key....

In your query how do you map the ? (parameters) to
fields/alternate values? (Each field has an original
value, a current value if changed since the data was
read). Thanks for your help.
-----Original Message-----
Here is an example of an update query I did with an access DB.
Compare with Yours.

Regards - OHM

'setup People Update Command

peopleUpdateCmd.CommandText = "UPDATE People SET Address1 = ?,
Address2 = ?, Address3 = ?, Address4 = ?, Country" & _

" = ?, County = ?, DOB = ?, Email = ?, FirstName = ?, [Home Phone] =
?, LastName " & _

"= ?, MiddleInnitial = ?, [Mobile Fone] = ?, [Post Code] = ?, Town =
? WHERE (ID " & _

"= ?) AND (Address1 = ?) AND (Address2 = ?) AND (Address3 = ?) AND
(Address4 = ?)" & _

" AND (Country = ?) AND (County = ?) AND (DOB = ?) AND (Email = ? OR
? IS NULL AN" & _

"D Email IS NULL) AND (FirstName = ?) AND ([Home Phone] = ?) AND
(LastName = ?) A" & _

"ND (MiddleInnitial = ? OR ? IS NULL AND MiddleInnitial IS NULL) AND
([Mobile Fon" & _

"e] = ? OR ? IS NULL AND [Mobile Fone] IS NULL) AND ([Post Code] =
?) AND (Town =" & _

" ?)"





Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
"rriness" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I'm getting an inconsistent failure when trying to save
data in ADO.Net.

I'm using an Access database with a simple query - SELECT
StudentID, FirstName, LastName FROM Students - and have
no other users in the database. I keep getting the
message 'Operation must use an updateable query.'

Process seems to work on some PC's, not others. Is there
a difference in .Net framework versions? Or some other
place to look for the problem? I'm using a datatable, and
dataadapter with command builder, using disconnected
data. Help!

.


Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
Nov 20 '05 #7
I'm already using a command builder (see original post).
I have a valid SELECT statement, valid connection, and
send a datatable into the update method of the data
adapter.

Part of my confusion with your suggested query using
parameters is correlating parameters to original and
current values of a datarow, and how to ignore a field
which cannot change (autonumber). It's starting to look
easier to just build a command and execute a non-query...

Thanks for your help.
-----Original Message-----
Hello,

As bernie points out , you can use the CommandBuilder class. However, it haslimitations, if you SQL queries are simple, then it may suit you to do this.
As far as the parameters are concerned, the ? characters are placeholders asconnecting with OLEDB you cannot have named parameters as you do in SQL, sothe Parameters have to be read in the order of the SQL statement and the ?means an unknown value being returned.( Thats why its a question mark ).
Try the builder, you can find references in the help.

Regards - OHM
rriness wrote:
I was hoping not to have to build my own command - the
select statement meets the requirements of a single
table, with a one field primary key....

In your query how do you map the ? (parameters) to
fields/alternate values? (Each field has an original
value, a current value if changed since the data was
read). Thanks for your help.
-----Original Message-----
Here is an example of an update query I did with an access DB. Compare with Yours.

Regards - OHM

'setup People Update Command

peopleUpdateCmd.CommandText = "UPDATE People SET Address1 = ?, Address2 = ?, Address3 = ?, Address4 = ?, Country" & _

" = ?, County = ?, DOB = ?, Email = ?, FirstName = ?, [Home Phone] = ?, LastName " & _

"= ?, MiddleInnitial = ?, [Mobile Fone] = ?, [Post Code] = ?, Town = ? WHERE (ID " & _

"= ?) AND (Address1 = ?) AND (Address2 = ?) AND (Address3 = ?) AND (Address4 = ?)" & _

" AND (Country = ?) AND (County = ?) AND (DOB = ?) AND (Email = ? OR ? IS NULL AN" & _

"D Email IS NULL) AND (FirstName = ?) AND ([Home Phone] = ?) AND (LastName = ?) A" & _

"ND (MiddleInnitial = ? OR ? IS NULL AND MiddleInnitial IS NULL) AND ([Mobile Fon" & _

"e] = ? OR ? IS NULL AND [Mobile Fone] IS NULL) AND ([Post Code] = ?) AND (Town =" & _

" ?)"





Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com "rriness" <an*******@discussions.microsoft.com> wrote in message news:03****************************@phx.gbl...
I'm getting an inconsistent failure when trying to save data in ADO.Net.

I'm using an Access database with a simple query - SELECT StudentID, FirstName, LastName FROM Students - and have no other users in the database. I keep getting the
message 'Operation must use an updateable query.'

Process seems to work on some PC's, not others. Is there a difference in .Net framework versions? Or some other place to look for the problem? I'm using a datatable, and dataadapter with command builder, using disconnected
data. Help!
.

Best Regards - OHMBest Regards - OHM

On**********@BTInternet.Com

.

Nov 20 '05 #8
Look,
If you really get stuck, let me have your project and I will try
and resolve it for you. Update commands can get really messy and
complicated. If your new to it, it can be a real pain.

Regards - OHM
rriness wrote:
I'm already using a command builder (see original post).
I have a valid SELECT statement, valid connection, and
send a datatable into the update method of the data
adapter.

Part of my confusion with your suggested query using
parameters is correlating parameters to original and
current values of a datarow, and how to ignore a field
which cannot change (autonumber). It's starting to look
easier to just build a command and execute a non-query...

Thanks for your help.
-----Original Message-----
Hello,

As bernie points out , you can use the CommandBuilder class.
However, it has limitations, if you SQL queries are simple, then it
may suit you to do this.

As far as the parameters are concerned, the ? characters are
placeholders as connecting with OLEDB you cannot have named
parameters as you do in SQL, so the Parameters have to be read in
the order of the SQL statement and the ? means an unknown value
being returned.( Thats why its a question mark ).

Try the builder, you can find references in the help.

Regards - OHM
rriness wrote:
I was hoping not to have to build my own command - the
select statement meets the requirements of a single
table, with a one field primary key....

In your query how do you map the ? (parameters) to
fields/alternate values? (Each field has an original
value, a current value if changed since the data was
read). Thanks for your help.

-----Original Message-----
Here is an example of an update query I did with an access DB.
Compare with Yours.

Regards - OHM

'setup People Update Command

peopleUpdateCmd.CommandText = "UPDATE People SET Address1 = ?,
Address2 = ?, Address3 = ?, Address4 = ?, Country" & _

" = ?, County = ?, DOB = ?, Email = ?, FirstName = ?, [Home Phone]
= ?, LastName " & _

"= ?, MiddleInnitial = ?, [Mobile Fone] = ?, [Post Code] = ?, Town
= ? WHERE (ID " & _

"= ?) AND (Address1 = ?) AND (Address2 = ?) AND (Address3 = ?) AND
(Address4 = ?)" & _

" AND (Country = ?) AND (County = ?) AND (DOB = ?) AND (Email = ?
OR ? IS NULL AN" & _

"D Email IS NULL) AND (FirstName = ?) AND ([Home Phone] = ?) AND
(LastName = ?) A" & _

"ND (MiddleInnitial = ? OR ? IS NULL AND MiddleInnitial IS NULL)
AND ([Mobile Fon" & _

"e] = ? OR ? IS NULL AND [Mobile Fone] IS NULL) AND ([Post Code] =
?) AND (Town =" & _

" ?)"





Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
"rriness" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
> I'm getting an inconsistent failure when trying to save
> data in ADO.Net.
>
> I'm using an Access database with a simple query - SELECT
> StudentID, FirstName, LastName FROM Students - and have
> no other users in the database. I keep getting the
> message 'Operation must use an updateable query.'
>
> Process seems to work on some PC's, not others. Is there
> a difference in .Net framework versions? Or some other
> place to look for the problem? I'm using a datatable, and
> dataadapter with command builder, using disconnected
> data. Help!
.


Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
.


Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Suzanne | last post by:
Hi All I'm having problems getting my data adapter to throw a concurrency exception with an INSERT command. I want to throw a concurrency exception if an attempt is made to enter a row into...
4
by: William | last post by:
After much frustration I was able to update my data store via code only. Using the data adapter was the only way I was able to set up all the objects written in my code. Basically, I cheated by...
9
by: Brad | last post by:
I have written some code to manipulate data/records in a MASTER (order header) and DETAIL (order details) tables. What I have written is too extensive to post but essentially trying to: 1....
1
by: bennett | last post by:
I'm trying to write an ASPX page that uses an OleDbDataAdapter to get data from a SQL Server database. When I test the connection, it returns success, and when I preview the data using the...
6
by: rcoco | last post by:
Hi, I have a datagrid that is ment to insert data. But when I run the form only the header appears. I would like some advise from you all and solve this problem I'm using visual studio 2003. My...
6
by: Suresh | last post by:
Hi All, I am fetching a dataset from the database under some condition. After this I create a data table. Traverse in the original dataset & add each row to created data table as it is through...
0
by: mwenz | last post by:
I am trying to update an Access table using OLEDB in VB.Net 2005. I can add rows but I cannot update them. Code to instantiate the Access database and table... Dim conn As New...
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.