Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - UpdateQuery problem

 
Thread Tools Search this Thread
Old 05-20-2007, 10:45 PM   #1
Default UpdateQuery problem


Hi,

I am trying to build updateable GridView. I can't see the problem with
this code but it simply doesnt update the DataSet.

It doesnt work with or without
'OldValuesParameterFormatString="original_{0}"'.

It works updates data when UpdateCommand has "...WHERE (id = 1)", so I
think that problem is with @original_value, it is problably empty...
Do you know why?

<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField
DataField="id"
HeaderText="id"
InsertVisible="False"
ReadOnly="True"
SortExpression="id" />
<asp:BoundField
DataField="topic"
HeaderText="topic"
SortExpression="topic" />
</Columns>
</asp:GridView>

<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$
ConnectionStringsrojectsConnectionString %>"
SelectCommand="SELECT id, topic FROM Projects"
UpdateCommand="UPDATE Projects SET topic = @topic WHERE
(id = @original_id)"
OldValuesParameterFormatString="original_{0}">
<UpdateParameters>
<asparameter Name="topic" Type="String" />
<asparameter Name="original_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>

Thanks in advance,
Etam.



etam
  Reply With Quote
Old 05-20-2007, 11:43 PM   #2
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
 
Posts: n/a
Default RE: UpdateQuery problem
Shouldn't it be "WHERE ID = @ID" ?
Try it.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"etam" wrote:

> Hi,
>
> I am trying to build updateable GridView. I can't see the problem with
> this code but it simply doesnt update the DataSet.
>
> It doesnt work with or without
> 'OldValuesParameterFormatString="original_{0}"'.
>
> It works updates data when UpdateCommand has "...WHERE (id = 1)", so I
> think that problem is with @original_value, it is problably empty...
> Do you know why?
>
> <asp:GridView
> ID="GridView1"
> runat="server"
> AutoGenerateColumns="False"
> DataSourceID="SqlDataSource1">
> <Columns>
> <asp:CommandField ShowEditButton="True" />
> <asp:BoundField
> DataField="id"
> HeaderText="id"
> InsertVisible="False"
> ReadOnly="True"
> SortExpression="id" />
> <asp:BoundField
> DataField="topic"
> HeaderText="topic"
> SortExpression="topic" />
> </Columns>
> </asp:GridView>
>
> <asp:SqlDataSource
> ID="SqlDataSource1"
> runat="server"
> ConnectionString="<%$
> ConnectionStringsrojectsConnectionString %>"
> SelectCommand="SELECT id, topic FROM Projects"
> UpdateCommand="UPDATE Projects SET topic = @topic WHERE
> (id = @original_id)"
> OldValuesParameterFormatString="original_{0}">
> <UpdateParameters>
> <asparameter Name="topic" Type="String" />
> <asparameter Name="original_id" Type="Int32" />
> </UpdateParameters>
> </asp:SqlDataSource>
>
> Thanks in advance,
> Etam.
>
>



=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
  Reply With Quote
Old 05-21-2007, 12:15 AM   #3
etam
 
Posts: n/a
Default Re: UpdateQuery problem
On 21 Maj, 00:43, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.com> wrote:
> Shouldn't it be "WHERE ID = @ID" ?
> Try it.
> Peter
> --
> Site: http://www.eggheadcafe.com
> UnBlog: http://petesbloggerama.blogspot.com
> Short urls & more: http://ittyurl.net
>
> "etam" wrote:
> > Hi,

>
> > I am trying to build updateable GridView. I can't see the problem with
> > this code but it simply doesnt update the DataSet.

>
> > It doesnt work with or without
> > 'OldValuesParameterFormatString="original_{0}"'.

>
> > It works updates data when UpdateCommand has "...WHERE (id = 1)", so I
> > think that problem is with @original_value, it is problably empty...
> > Do you know why?

>
> > <asp:GridView
> > ID="GridView1"
> > runat="server"
> > AutoGenerateColumns="False"
> > DataSourceID="SqlDataSource1">
> > <Columns>
> > <asp:CommandField ShowEditButton="True" />
> > <asp:BoundField
> > DataField="id"
> > HeaderText="id"
> > InsertVisible="False"
> > ReadOnly="True"
> > SortExpression="id" />
> > <asp:BoundField
> > DataField="topic"
> > HeaderText="topic"
> > SortExpression="topic" />
> > </Columns>
> > </asp:GridView>

>
> > <asp:SqlDataSource
> > ID="SqlDataSource1"
> > runat="server"
> > ConnectionString="<%$
> > ConnectionStringsrojectsConnectionString %>"
> > SelectCommand="SELECT id, topic FROM Projects"
> > UpdateCommand="UPDATE Projects SET topic = @topic WHERE
> > (id = @original_id)"
> > OldValuesParameterFormatString="original_{0}">
> > <UpdateParameters>
> > <asparameter Name="topic" Type="String" />
> > <asparameter Name="original_id" Type="Int32" />
> > </UpdateParameters>
> > </asp:SqlDataSource>

>
> > Thanks in advance,
> > Etam.


Nope , it doesn't work.



etam
  Reply With Quote
Old 05-21-2007, 02:27 PM   #4
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
 
Posts: n/a
Default Re: UpdateQuery problem
You would have to change the parameter to ID also. I assume that ID is a
primary key?
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"etam" wrote:

> On 21 Maj, 00:43, Peter Bromberg [C# MVP]
> <pbromb...@yahoo.yabbadabbadoo.com> wrote:
> > Shouldn't it be "WHERE ID = @ID" ?
> > Try it.
> > Peter
> > --
> > Site: http://www.eggheadcafe.com
> > UnBlog: http://petesbloggerama.blogspot.com
> > Short urls & more: http://ittyurl.net
> >
> > "etam" wrote:
> > > Hi,

> >
> > > I am trying to build updateable GridView. I can't see the problem with
> > > this code but it simply doesnt update the DataSet.

> >
> > > It doesnt work with or without
> > > 'OldValuesParameterFormatString="original_{0}"'.

> >
> > > It works updates data when UpdateCommand has "...WHERE (id = 1)", so I
> > > think that problem is with @original_value, it is problably empty...
> > > Do you know why?

> >
> > > <asp:GridView
> > > ID="GridView1"
> > > runat="server"
> > > AutoGenerateColumns="False"
> > > DataSourceID="SqlDataSource1">
> > > <Columns>
> > > <asp:CommandField ShowEditButton="True" />
> > > <asp:BoundField
> > > DataField="id"
> > > HeaderText="id"
> > > InsertVisible="False"
> > > ReadOnly="True"
> > > SortExpression="id" />
> > > <asp:BoundField
> > > DataField="topic"
> > > HeaderText="topic"
> > > SortExpression="topic" />
> > > </Columns>
> > > </asp:GridView>

> >
> > > <asp:SqlDataSource
> > > ID="SqlDataSource1"
> > > runat="server"
> > > ConnectionString="<%$
> > > ConnectionStringsrojectsConnectionString %>"
> > > SelectCommand="SELECT id, topic FROM Projects"
> > > UpdateCommand="UPDATE Projects SET topic = @topic WHERE
> > > (id = @original_id)"
> > > OldValuesParameterFormatString="original_{0}">
> > > <UpdateParameters>
> > > <asparameter Name="topic" Type="String" />
> > > <asparameter Name="original_id" Type="Int32" />
> > > </UpdateParameters>
> > > </asp:SqlDataSource>

> >
> > > Thanks in advance,
> > > Etam.

>
> Nope , it doesn't work.
>
>



=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
  Reply With Quote
Old 05-21-2007, 11:26 PM   #5
etam
 
Posts: n/a
Default Re: UpdateQuery problem
On 21 Maj, 15:27, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.com> wrote:
> You would have to change the parameter to ID also. I assume that ID is a
> primary key?
> --
> Site: http://www.eggheadcafe.com
> UnBlog: http://petesbloggerama.blogspot.com
> Short urls & more: http://ittyurl.net
>
> "etam" wrote:
> > On 21 Maj, 00:43, Peter Bromberg [C# MVP]
> > <pbromb...@yahoo.yabbadabbadoo.com> wrote:
> > > Shouldn't it be "WHERE ID = @ID" ?
> > > Try it.
> > > Peter
> > > --
> > > Site: http://www.eggheadcafe.com
> > > UnBlog: http://petesbloggerama.blogspot.com
> > > Short urls & more: http://ittyurl.net

>
> > > "etam" wrote:
> > > > Hi,

>
> > > > I am trying to build updateable GridView. I can't see the problem with
> > > > this code but it simply doesnt update the DataSet.

>
> > > > It doesnt work with or without
> > > > 'OldValuesParameterFormatString="original_{0}"'.

>
> > > > It works updates data when UpdateCommand has "...WHERE (id = 1)", so I
> > > > think that problem is with @original_value, it is problably empty...
> > > > Do you know why?

>
> > > > <asp:GridView
> > > > ID="GridView1"
> > > > runat="server"
> > > > AutoGenerateColumns="False"
> > > > DataSourceID="SqlDataSource1">
> > > > <Columns>
> > > > <asp:CommandField ShowEditButton="True" />
> > > > <asp:BoundField
> > > > DataField="id"
> > > > HeaderText="id"
> > > > InsertVisible="False"
> > > > ReadOnly="True"
> > > > SortExpression="id" />
> > > > <asp:BoundField
> > > > DataField="topic"
> > > > HeaderText="topic"
> > > > SortExpression="topic" />
> > > > </Columns>
> > > > </asp:GridView>

>
> > > > <asp:SqlDataSource
> > > > ID="SqlDataSource1"
> > > > runat="server"
> > > > ConnectionString="<%$
> > > > ConnectionStringsrojectsConnectionString %>"
> > > > SelectCommand="SELECT id, topic FROM Projects"
> > > > UpdateCommand="UPDATE Projects SET topic = @topic WHERE
> > > > (id = @original_id)"
> > > > OldValuesParameterFormatString="original_{0}">
> > > > <UpdateParameters>
> > > > <asparameter Name="topic" Type="String" />
> > > > <asparameter Name="original_id" Type="Int32" />
> > > > </UpdateParameters>
> > > > </asp:SqlDataSource>

>
> > > > Thanks in advance,
> > > > Etam.

>
> > Nope , it doesn't work.


Finally! <asparameter Name="original_id" Type="Int64" /> works! It
was 32 :/.
Thanks for help!



etam
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dial Up Problem smackedass A+ Certification 3 02-02-2007 11:59 PM
Re: Virus Problem ** Help!** David BlandIII A+ Certification 1 03-02-2004 06:00 PM
Pioneer DVR3100S problem with Satellite receiver Samsung DCR 9500 Fredrik Bengtsson DVD Video 0 12-12-2003 02:32 PM
Re: Serious Computer Problem hootnholler A+ Certification 1 11-24-2003 12:18 PM
Re: Serious Computer Problem Bret A+ Certification 0 11-19-2003 12:51 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46