473,388 Members | 1,177 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,388 software developers and data experts.

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="<%$
ConnectionStrings:ProjectsConnectionString %>"
SelectCommand="SELECT id, topic FROM Projects"
UpdateCommand="UPDATE Projects SET topic = @topic WHERE
(id = @original_id)"
OldValuesParameterFormatString="original_{0}">
<UpdateParameters>
<asp:Parameter Name="topic" Type="String" />
<asp:Parameter Name="original_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>

Thanks in advance,
Etam.

May 20 '07 #1
4 3836
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="<%$
ConnectionStrings:ProjectsConnectionString %>"
SelectCommand="SELECT id, topic FROM Projects"
UpdateCommand="UPDATE Projects SET topic = @topic WHERE
(id = @original_id)"
OldValuesParameterFormatString="original_{0}">
<UpdateParameters>
<asp:Parameter Name="topic" Type="String" />
<asp:Parameter Name="original_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>

Thanks in advance,
Etam.

May 20 '07 #2
On 21 Maj, 00:43, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
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="<%$
ConnectionStrings:ProjectsConnectionString %>"
SelectCommand="SELECT id, topic FROM Projects"
UpdateCommand="UPDATE Projects SET topic = @topic WHERE
(id = @original_id)"
OldValuesParameterFormatString="original_{0}">
<UpdateParameters>
<asp:Parameter Name="topic" Type="String" />
<asp:Parameter Name="original_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Thanks in advance,
Etam.
Nope :(, it doesn't work.

May 20 '07 #3
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.comwrote:
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="<%$
ConnectionStrings:ProjectsConnectionString %>"
SelectCommand="SELECT id, topic FROM Projects"
UpdateCommand="UPDATE Projects SET topic = @topic WHERE
(id = @original_id)"
OldValuesParameterFormatString="original_{0}">
<UpdateParameters>
<asp:Parameter Name="topic" Type="String" />
<asp:Parameter Name="original_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Thanks in advance,
Etam.

Nope :(, it doesn't work.

May 21 '07 #4
On 21 Maj, 15:27, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
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.comwrote:
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="<%$
ConnectionStrings:ProjectsConnectionString %>"
SelectCommand="SELECT id, topic FROM Projects"
UpdateCommand="UPDATE Projects SET topic = @topic WHERE
(id = @original_id)"
OldValuesParameterFormatString="original_{0}">
<UpdateParameters>
<asp:Parameter Name="topic" Type="String" />
<asp:Parameter Name="original_id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Thanks in advance,
Etam.
Nope :(, it doesn't work.
Finally! <asp:Parameter Name="original_id" Type="Int64" /works! It
was 32 :/.
Thanks for help!

May 21 '07 #5

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

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
0
by: hiisikukko | last post by:
I have created project management software with Java and MySql and i works fine. This applet gets and writes information directly to MySql database. Problem is that those sqlClauses below(update...
117
by: Peter Olcott | last post by:
www.halting-problem.com
0
by: jerim | last post by:
Hi I have the following Problem: I have an Access DB. Tablename: Formate; TableColoumns: ID (=Numeric) Name (=string)
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
3
by: =?Utf-8?B?TTFpUw==?= | last post by:
I have a GridView control with a template column that I use to display my record data. I’ve included an EditItemTemplate with textboxes bound to the GridView for editing. On my SqlDataSource I...
5
Killer911
by: Killer911 | last post by:
language C#. it`s a windows based app. database is sql. I have all my Query`s up and working on my DataB, just having problems with the code to go with it. It contains roles: I...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.