I am using SqlCommandBuilder to update,insert,delete my data. I can do for insert and
delete. My code is

string sql=" select * from "+dbname;
SqlDataAdapter sdata=new SqlDataAdapter();
sdata.SelectCommand=new SqlCommand(sql,scon);
SqlCommandBuilder scom=new SqlCommandBuilder(sdata);
sdata.UpdateCommand=scom.GetUpdateCommand();
sdata.RowUpdating+=new SqlRowUpdatingEventHandler(sdata_RowUpdating);
sdata.RowUpdated+=new SqlRowUpdatedEventHandler(sdata_RowUpdated);
sdata.Update(ds,dbname);
but when I reach the SqlRowUpdating Event my event argument command is undefined. But my
dataadapter take the update command correctly.
How can I solve this problem
Thanks for all.

Re: SqlCommandBuilder unable to Update a dataset by William

William
Sun Jul 25 13:48:40 CDT 2004

When you say it's undefined, what is happening? From the subject of your
post I take it the update is not working ie nothing is being updated in the
db? You said the Adapter is taking the Update command fine - is that to say
that no exceptions are being raised or simply that you can specify an update
command? If you call update and nothing happens to the db but no exception
is thrown, the first thing to do is verify that the dataset's HasChanges is
true. If it is not, then your problem is that none of your edits are being
seen. You can probably resolve this by using EndCurrentEdit. However if
Haschanges is true then you want to check the table and verify that you have
a Primary Key and that it's included in your Select statement. You'll also
want to make sure that you have no reserved words in your table's field
names. You may need to set the QuoteSuffix and .QuotePrefix properties
(usually to [ and ] respectively) Also verify that you aren't raising any
exceptions and just eating them.. that you're using some sort of
notification for exceptions.

Sometimes when Access doesn't have the appropriate permisssions then it
won't allow writes (just an FYI for general knowledge- you aare using
SqlServver so this isn't the problem - althogh verifying that you have the
corect permissons is always a pretty good idea.

If none of this helps let me know and I'll see what we can do from there.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
"caldera" <caldera@cc.com> wrote in message
news:OKSVcmicEHA.3864@TK2MSFTNGP10.phx.gbl...
> I am using SqlCommandBuilder to update,insert,delete my data. I can do for
insert and
> delete. My code is
>
> string sql=" select * from "+dbname;
> SqlDataAdapter sdata=new SqlDataAdapter();
> sdata.SelectCommand=new SqlCommand(sql,scon);
> SqlCommandBuilder scom=new SqlCommandBuilder(sdata);
> sdata.UpdateCommand=scom.GetUpdateCommand();
> sdata.RowUpdating+=new SqlRowUpdatingEventHandler(sdata_RowUpdating);
> sdata.RowUpdated+=new SqlRowUpdatedEventHandler(sdata_RowUpdated);
> sdata.Update(ds,dbname);
> but when I reach the SqlRowUpdating Event my event argument command is
undefined. But my
> dataadapter take the update command correctly.
> How can I solve this problem
> Thanks for all.
>
>



Re: SqlCommandBuilder unable to Update a dataset by caldera

caldera
Sun Jul 25 23:46:43 CDT 2004

This is a multi-part message in MIME format.

------=_NextPart_000_02B3_01C472E4.B289ECF0
Content-Type: text/plain;
charset="iso-8859-9"
Content-Transfer-Encoding: quoted-printable

Thank you. I solved the problem. As you said, my problem is related to =
edit the dataset. I change the values using =
ds.Tables[0].Row[0].ItemArray[1]=3D it doesn't change the rowversion of =
the dataset. I use a datarow associated to this row then edit the =
dataset. Then rowversion was changed.
Thanks for your answer.

"William Ryan eMVP" <dotnetguru@comcast.nospam.net> wrote in message =
news:OoJh6gncEHA.3664@TK2MSFTNGP12.phx.gbl...
When you say it's undefined, what is happening? From the subject of =
your
post I take it the update is not working ie nothing is being updated =
in the
db? You said the Adapter is taking the Update command fine - is that =
to say
that no exceptions are being raised or simply that you can specify an =
update
command? If you call update and nothing happens to the db but no =
exception
is thrown, the first thing to do is verify that the dataset's =
HasChanges is
true. If it is not, then your problem is that none of your edits are =
being
seen. You can probably resolve this by using EndCurrentEdit. However =
if
Haschanges is true then you want to check the table and verify that =
you have
a Primary Key and that it's included in your Select statement. You'll =
also
want to make sure that you have no reserved words in your table's =
field
names. You may need to set the QuoteSuffix and .QuotePrefix =
properties
(usually to [ and ] respectively) Also verify that you aren't =
raising any
exceptions and just eating them.. that you're using some sort of
notification for exceptions.

Sometimes when Access doesn't have the appropriate permisssions then =
it
won't allow writes (just an FYI for general knowledge- you aare using
SqlServver so this isn't the problem - althogh verifying that you have =
the
corect permissons is always a pretty good idea.

If none of this helps let me know and I'll see what we can do from =
there.

HTH,

Bill

--=20
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
"caldera" <caldera@cc.com> wrote in message
news:OKSVcmicEHA.3864@TK2MSFTNGP10.phx.gbl...
> I am using SqlCommandBuilder to update,insert,delete my data. I can =
do for
insert and
> delete. My code is
>
> string sql=3D" select * from "+dbname;
> SqlDataAdapter sdata=3Dnew SqlDataAdapter();
> sdata.SelectCommand=3Dnew SqlCommand(sql,scon);
> SqlCommandBuilder scom=3Dnew SqlCommandBuilder(sdata);
> sdata.UpdateCommand=3Dscom.GetUpdateCommand();
> sdata.RowUpdating+=3Dnew =
SqlRowUpdatingEventHandler(sdata_RowUpdating);
> sdata.RowUpdated+=3Dnew SqlRowUpdatedEventHandler(sdata_RowUpdated);
> sdata.Update(ds,dbname);
> but when I reach the SqlRowUpdating Event my event argument command =
is
undefined. But my
> dataadapter take the update command correctly.
> How can I solve this problem
> Thanks for all.
>
>


------=_NextPart_000_02B3_01C472E4.B289ECF0
Content-Type: text/html;
charset="iso-8859-9"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-9">
<META content=3D"MSHTML 6.00.3790.118" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thank you. I solved the problem. As you =
said, my=20
problem is related to edit the dataset.&nbsp; I change the values using=20
ds.Tables[0].Row[0].ItemArray[1]=3D it doesn't change the rowversion of =
the=20
dataset. I use a datarow associated to this row then edit the dataset. =
Then=20
rowversion was changed.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for your answer.</FONT></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"William Ryan eMVP" &lt;<A=20
=
href=3D"mailto:dotnetguru@comcast.nospam.net">dotnetguru@comcast.nospam.n=
et</A>&gt;=20
wrote in message <A=20
=
href=3D"news:OoJh6gncEHA.3664@TK2MSFTNGP12.phx.gbl">news:OoJh6gncEHA.3664=
@TK2MSFTNGP12.phx.gbl</A>...</DIV>When=20
you say it's undefined, what is happening?&nbsp; From the subject of=20
your<BR>post I take it the update is not working ie nothing is being =
updated=20
in the<BR>db?&nbsp; You said the Adapter is taking the Update command =
fine -=20
is that to say<BR>that no exceptions are being raised or simply that =
you can=20
specify an update<BR>command? If you call update and nothing happens =
to the db=20
but no exception<BR>is thrown, the first thing to do is verify that =
the=20
dataset's HasChanges is<BR>true.&nbsp; If it is not, then your problem =
is that=20
none of your edits are being<BR>seen.&nbsp; You can probably resolve =
this by=20
using EndCurrentEdit.&nbsp; However if<BR>Haschanges is true then you =
want to=20
check the table and verify that you have<BR>a Primary Key and that =
it's=20
included in your Select statement.&nbsp; You'll also<BR>want to make =
sure that=20
you have no reserved words in your table's field<BR>names.&nbsp; You =
may need=20
to set the QuoteSuffix and .QuotePrefix properties<BR>(usually to =
[&nbsp; and=20
] respectively)&nbsp; Also verify that you aren't raising =
any<BR>exceptions=20
and just eating them.. that you're using some sort of<BR>notification =
for=20
exceptions.<BR><BR>Sometimes when Access doesn't have the appropriate=20
permisssions then it<BR>won't allow writes (just an FYI for general =
knowledge-=20
you aare using<BR>SqlServver so this isn't the problem - althogh =
verifying=20
that you have the<BR>corect permissons is always a pretty good =
idea.<BR><BR>If=20
none of this helps let me know and I'll see what we can do from=20
there.<BR><BR>HTH,<BR><BR>Bill<BR><BR>-- <BR>W.G. Ryan MVP Windows -=20
Embedded<BR><BR>Have an opinion on the effectiveness of Microsoft =
Embedded=20
newsgroups?<BR>Let Microsoft know!<BR><A=20
=
href=3D"https://www.windowsembeddedeval.com/community/newsgroups">https:/=
/www.windowsembeddedeval.com/community/newsgroups</A><BR>"caldera"=20
&lt;<A href=3D"mailto:caldera@cc.com">caldera@cc.com</A>&gt; wrote in=20
message<BR><A=20
=
href=3D"news:OKSVcmicEHA.3864@TK2MSFTNGP10.phx.gbl">news:OKSVcmicEHA.3864=
@TK2MSFTNGP10.phx.gbl</A>...<BR>&gt;=20
I am using SqlCommandBuilder to update,insert,delete my data. I can do =

for<BR>insert and<BR>&gt; delete.&nbsp; My code is<BR>&gt;<BR>&gt; =
string=20
sql=3D" select * from "+dbname;<BR>&gt; SqlDataAdapter sdata=3Dnew=20
SqlDataAdapter();<BR>&gt; sdata.SelectCommand=3Dnew=20
SqlCommand(sql,scon);<BR>&gt; SqlCommandBuilder scom=3Dnew=20
SqlCommandBuilder(sdata);<BR>&gt;=20
sdata.UpdateCommand=3Dscom.GetUpdateCommand();<BR>&gt; =
sdata.RowUpdating+=3Dnew=20
SqlRowUpdatingEventHandler(sdata_RowUpdating);<BR>&gt; =
sdata.RowUpdated+=3Dnew=20
SqlRowUpdatedEventHandler(sdata_RowUpdated);<BR>&gt;=20
sdata.Update(ds,dbname);<BR>&gt; but when I reach the SqlRowUpdating =
Event my=20
event argument command is<BR>undefined.&nbsp; But my<BR>&gt; =
dataadapter take=20
the update command correctly.<BR>&gt; How can I solve this =
problem<BR>&gt;=20
Thanks for all.<BR>&gt;<BR>&gt;<BR><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_02B3_01C472E4.B289ECF0--