Connecting Tech Pros Worldwide Help | Site Map

data adapter update fails

rriness
Guest
 
Posts: n/a
#1: Nov 20 '05
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!
One Handed Man [ OHM ]
Guest
 
Posts: n/a
#2: Nov 20 '05

re: data adapter update fails


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 OneHandedMan@BTInternet.Com
"rriness" <anonymous@discussions.microsoft.com> wrote in message
news:03e201c3b867$1261d6d0$a501280a@phx.gbl...[color=blue]
> 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![/color]


rriness
Guest
 
Posts: n/a
#3: Nov 20 '05

re: data adapter update fails


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.
[color=blue]
>-----Original Message-----
>Here is an example of an update query I did with an[/color]
access DB. Compare with[color=blue]
>Yours.
>
>Regards - OHM
>
>'setup People Update Command
>
>peopleUpdateCmd.CommandText = "UPDATE People SET[/color]
Address1 = ?, Address2 = ?,[color=blue]
>Address3 = ?, Address4 = ?, Country" & _
>
>" = ?, County = ?, DOB = ?, Email = ?, FirstName = ?,[/color]
[Home Phone] = ?,[color=blue]
>LastName " & _
>
>"= ?, MiddleInnitial = ?, [Mobile Fone] = ?, [Post Code][/color]
= ?, Town = ? WHERE[color=blue]
>(ID " & _
>
>"= ?) AND (Address1 = ?) AND (Address2 = ?) AND[/color]
(Address3 = ?) AND (Address4[color=blue]
>= ?)" & _
>
>" AND (Country = ?) AND (County = ?) AND (DOB = ?) AND[/color]
(Email = ? OR ? IS[color=blue]
>NULL AN" & _
>
>"D Email IS NULL) AND (FirstName = ?) AND ([Home Phone][/color]
= ?) AND (LastName =[color=blue]
>?) A" & _
>
>"ND (MiddleInnitial = ? OR ? IS NULL AND MiddleInnitial[/color]
IS NULL) AND[color=blue]
>([Mobile Fon" & _
>
>"e] = ? OR ? IS NULL AND [Mobile Fone] IS NULL) AND[/color]
([Post Code] = ?) AND[color=blue]
>(Town =" & _
>
>" ?)"
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>Best Regards - OHMBest Regards - OHM[/color]
OneHandedMan@BTInternet.Com[color=blue]
>"rriness" <anonymous@discussions.microsoft.com> wrote in[/color]
message[color=blue]
>news:03e201c3b867$1261d6d0$a501280a@phx.gbl...[color=green]
>> I'm getting an inconsistent failure when trying to save
>> data in ADO.Net.
>>
>> I'm using an Access database with a simple query -[/color][/color]
SELECT[color=blue][color=green]
>> 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[/color][/color]
there[color=blue][color=green]
>> a difference in .Net framework versions? Or some other
>> place to look for the problem? I'm using a datatable,[/color][/color]
and[color=blue][color=green]
>> dataadapter with command builder, using disconnected
>> data. Help![/color]
>
>
>.
>[/color]
Bernie Yaeger
Guest
 
Posts: n/a
#4: Nov 20 '05

re: data adapter update fails


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" <anonymous@discussions.microsoft.com> wrote in message
news:03e201c3b867$1261d6d0$a501280a@phx.gbl...[color=blue]
> 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![/color]


Cor
Guest
 
Posts: n/a
#5: Nov 20 '05

re: data adapter update fails


Hi rriness,

[color=blue]
> Process seems to work on some PC's, not others. Is there
> a difference in .Net framework versions?[/color]

Yes

But you can load both on one computer

I hope this helps a little bit?

Cor


One Handed Man [ OHM ]
Guest
 
Posts: n/a
#6: Nov 20 '05

re: data adapter update fails


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:[color=blue]
> 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" <anonymous@discussions.microsoft.com> wrote in message
> news:03e201c3b867$1261d6d0$a501280a@phx.gbl...[color=green]
>> 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![/color][/color]

Best Regards - OHMBest Regards - OHM OneHandedMan@BTInternet.Com


One Handed Man [ OHM ]
Guest
 
Posts: n/a
#7: Nov 20 '05

re: data adapter update fails


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:[color=blue]
> 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.
>[color=green]
>> -----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 OneHandedMan@BTInternet.Com
>> "rriness" <anonymous@discussions.microsoft.com> wrote in message
>> news:03e201c3b867$1261d6d0$a501280a@phx.gbl...[color=darkred]
>>> 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![/color]
>>
>>
>> .[/color][/color]

Best Regards - OHMBest Regards - OHM OneHandedMan@BTInternet.Com


rriness
Guest
 
Posts: n/a
#8: Nov 20 '05

re: data adapter update fails


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.
[color=blue]
>-----Original Message-----
>Hello,
>
>As bernie points out , you can use the CommandBuilder[/color]
class. However, it has[color=blue]
>limitations, if you SQL queries are simple, then it may[/color]
suit you to do this.[color=blue]
>
>As far as the parameters are concerned, the ? characters[/color]
are placeholders as[color=blue]
>connecting with OLEDB you cannot have named parameters[/color]
as you do in SQL, so[color=blue]
>the Parameters have to be read in the order of the SQL[/color]
statement and the ?[color=blue]
>means an unknown value being returned.( Thats why its a[/color]
question mark ).[color=blue]
>
>Try the builder, you can find references in the help.
>
>Regards - OHM
>
>
>rriness wrote:[color=green]
>> 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.
>>[color=darkred]
>>> -----Original Message-----
>>> Here is an example of an update query I did with an[/color][/color][/color]
access DB.[color=blue][color=green][color=darkred]
>>> Compare with Yours.
>>>
>>> Regards - OHM
>>>
>>> 'setup People Update Command
>>>
>>> peopleUpdateCmd.CommandText = "UPDATE People SET[/color][/color][/color]
Address1 = ?,[color=blue][color=green][color=darkred]
>>> Address2 = ?, Address3 = ?, Address4 = ?, Country" & _
>>>
>>> " = ?, County = ?, DOB = ?, Email = ?, FirstName = ?,[/color][/color][/color]
[Home Phone] =[color=blue][color=green][color=darkred]
>>> ?, LastName " & _
>>>
>>> "= ?, MiddleInnitial = ?, [Mobile Fone] = ?, [Post[/color][/color][/color]
Code] = ?, Town =[color=blue][color=green][color=darkred]
>>> ? WHERE (ID " & _
>>>
>>> "= ?) AND (Address1 = ?) AND (Address2 = ?) AND[/color][/color][/color]
(Address3 = ?) AND[color=blue][color=green][color=darkred]
>>> (Address4 = ?)" & _
>>>
>>> " AND (Country = ?) AND (County = ?) AND (DOB = ?)[/color][/color][/color]
AND (Email = ? OR[color=blue][color=green][color=darkred]
>>> ? IS NULL AN" & _
>>>
>>> "D Email IS NULL) AND (FirstName = ?) AND ([Home[/color][/color][/color]
Phone] = ?) AND[color=blue][color=green][color=darkred]
>>> (LastName = ?) A" & _
>>>
>>> "ND (MiddleInnitial = ? OR ? IS NULL AND[/color][/color][/color]
MiddleInnitial IS NULL) AND[color=blue][color=green][color=darkred]
>>> ([Mobile Fon" & _
>>>
>>> "e] = ? OR ? IS NULL AND [Mobile Fone] IS NULL) AND[/color][/color][/color]
([Post Code] =[color=blue][color=green][color=darkred]
>>> ?) AND (Town =" & _
>>>
>>> " ?)"
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Best Regards - OHMBest Regards - OHM[/color][/color][/color]
OneHandedMan@BTInternet.Com[color=blue][color=green][color=darkred]
>>> "rriness" <anonymous@discussions.microsoft.com> wrote[/color][/color][/color]
in message[color=blue][color=green][color=darkred]
>>> news:03e201c3b867$1261d6d0$a501280a@phx.gbl...
>>>> I'm getting an inconsistent failure when trying to[/color][/color][/color]
save[color=blue][color=green][color=darkred]
>>>> data in ADO.Net.
>>>>
>>>> I'm using an Access database with a simple query -[/color][/color][/color]
SELECT[color=blue][color=green][color=darkred]
>>>> StudentID, FirstName, LastName FROM Students - and[/color][/color][/color]
have[color=blue][color=green][color=darkred]
>>>> 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[/color][/color][/color]
there[color=blue][color=green][color=darkred]
>>>> a difference in .Net framework versions? Or some[/color][/color][/color]
other[color=blue][color=green][color=darkred]
>>>> place to look for the problem? I'm using a[/color][/color][/color]
datatable, and[color=blue][color=green][color=darkred]
>>>> dataadapter with command builder, using disconnected
>>>> data. Help!
>>>
>>>
>>> .[/color][/color]
>
>Best Regards - OHMBest Regards - OHM[/color]
OneHandedMan@BTInternet.Com[color=blue]
>
>
>.
>[/color]
One Handed Man [ OHM ]
Guest
 
Posts: n/a
#9: Nov 20 '05

re: data adapter update fails


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:[color=blue]
> 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.
>[color=green]
>> -----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:[color=darkred]
>>> 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 OneHandedMan@BTInternet.Com
>>>> "rriness" <anonymous@discussions.microsoft.com> wrote in message
>>>> news:03e201c3b867$1261d6d0$a501280a@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!
>>>>
>>>>
>>>> .[/color]
>>
>> Best Regards - OHMBest Regards - OHM OneHandedMan@BTInternet.Com
>>
>>
>> .[/color][/color]

Best Regards - OHMBest Regards - OHM OneHandedMan@BTInternet.Com


Closed Thread