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

question about UpdateParameters.Add

Hi,

this code updates a table with the new values with the event RowUpdating of
a gridview.

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
GridView1.RowUpdating

Dim vlgn As Int16
vlgn = e.NewValues("vlg")

SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=" & vlgn

This works.
Now i want to use parameters (without creating a stored procedure). I tried
this but fails:

SqlDataSource1.UpdateParameters.Add("vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=vlg"

Could somebody give me the right syntax for this?
Thanks
Justin
Jul 30 '07 #1
7 5043
* Justin wrote, On 30-7-2007 16:11:
Hi,

this code updates a table with the new values with the event RowUpdating of
a gridview.

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
GridView1.RowUpdating

Dim vlgn As Int16
vlgn = e.NewValues("vlg")

SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=" & vlgn

This works.
Now i want to use parameters (without creating a stored procedure). I tried
this but fails:

SqlDataSource1.UpdateParameters.Add("vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=vlg"

Could somebody give me the right syntax for this?
Thanks
Justin

The parameter has a specific, unique name and usually starts with a '@'
sign:

SqlDataSource1.UpdateParameters.Add("@vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=@vlg"

Jesse
Jul 30 '07 #2
Thanks for the reply, but whe doing what you wrote, i get this very strange
error:
String was not recognized as a valid DateTime

...
"Jesse Houwing" <je***********@nospam-sogeti.nlschreef in bericht
news:On**************@TK2MSFTNGP02.phx.gbl...
>* Justin wrote, On 30-7-2007 16:11:
>Hi,

this code updates a table with the new values with the event RowUpdating
of a gridview.

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs ) Handles
GridView1.RowUpdating

Dim vlgn As Int16
vlgn = e.NewValues("vlg")

SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=" & vlgn

This works.
Now i want to use parameters (without creating a stored procedure). I
tried this but fails:

SqlDataSource1.UpdateParameters.Add("vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=vlg"

Could somebody give me the right syntax for this?
Thanks
Justin


The parameter has a specific, unique name and usually starts with a '@'
sign:

SqlDataSource1.UpdateParameters.Add("@vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=@vlg"

Jesse

Jul 30 '07 #3
>
"Jesse Houwing" <jesse.houw...@nospam-sogeti.nlschreef in berichtnews:On**************@TK2MSFTNGP02.phx.gbl. ..
* Justin wrote, On 30-7-2007 16:11:
Hi,
this code updates a table with the new values with the event RowUpdating
of a gridview.
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
GridView1.RowUpdating
Dim vlgn As Int16
vlgn = e.NewValues("vlg")
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=" & vlgn
This works.
Now i want to use parameters (without creating a stored procedure). I
tried this but fails:
SqlDataSource1.UpdateParameters.Add("vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=vlg"
Could somebody give me the right syntax for this?
Thanks
Justin
The parameter has a specific, unique name and usually starts with a '@'
sign:
SqlDataSource1.UpdateParameters.Add("@vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=@vlg"
On Jul 30, 10:42 am, "Justin" <h...@in.eswrote:
Thanks for the reply, but whe doing what you wrote, i get this very strange
error:
String was not recognized as a valid DateTime
It means the value you're passing in isn't a valid DateTime. What is
vlgn equal to?

Jul 30 '07 #4
The value is a smallint (50). It has nothing to do with datetime.
Has it something to do with the fact i use the event "RowUpdating"?
"Larry Bud" <la**********@yahoo.comschreef in bericht
news:11**********************@e16g2000pri.googlegr oups.com...
>
>>
"Jesse Houwing" <jesse.houw...@nospam-sogeti.nlschreef in
berichtnews:On**************@TK2MSFTNGP02.phx.gbl ...
>* Justin wrote, On 30-7-2007 16:11:
Hi,
>this code updates a table with the new values with the event
RowUpdating
of a gridview.
>Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs ) Handles
GridView1.RowUpdating
>Dim vlgn As Int16
vlgn = e.NewValues("vlg")
>SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=" & vlgn
>This works.
Now i want to use parameters (without creating a stored procedure). I
tried this but fails:
>SqlDataSource1.UpdateParameters.Add("vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=vlg"
>Could somebody give me the right syntax for this?
Thanks
Justin
The parameter has a specific, unique name and usually starts with a '@'
sign:
SqlDataSource1.UpdateParameters.Add("@vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=@vlg"
On Jul 30, 10:42 am, "Justin" <h...@in.eswrote:
>Thanks for the reply, but whe doing what you wrote, i get this very
strange
error:
String was not recognized as a valid DateTime

It means the value you're passing in isn't a valid DateTime. What is
vlgn equal to?

Jul 30 '07 #5
SAL
Hmmm, suspicious!
I'm going to guess that there's a date field in your grid and that the grid
is actually trying to update that field. I've had this happen on a few
occasions and what I had to do was to check the values that were in the row
and set the offending value to null, if that's what it should be...

Poke around a bit and you may find the same thing...

HTH
S
"Justin" <he*@in.eswrote in message
news:eq**************@TK2MSFTNGP02.phx.gbl...
The value is a smallint (50). It has nothing to do with datetime.
Has it something to do with the fact i use the event "RowUpdating"?
"Larry Bud" <la**********@yahoo.comschreef in bericht
news:11**********************@e16g2000pri.googlegr oups.com...
>>
>>>
"Jesse Houwing" <jesse.houw...@nospam-sogeti.nlschreef in
berichtnews:On**************@TK2MSFTNGP02.phx.gb l...

* Justin wrote, On 30-7-2007 16:11:
Hi,

this code updates a table with the new values with the event
RowUpdating
of a gridview.

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e
As
System.Web.UI.WebControls.GridViewUpdateEventArg s) Handles
GridView1.RowUpdating

Dim vlgn As Int16
vlgn = e.NewValues("vlg")

SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=" & vlgn

This works.
Now i want to use parameters (without creating a stored procedure). I
tried this but fails:

SqlDataSource1.UpdateParameters.Add("vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=vlg"

Could somebody give me the right syntax for this?
Thanks
Justin

The parameter has a specific, unique name and usually starts with a
'@'
sign:

SqlDataSource1.UpdateParameters.Add("@vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=@vlg"
On Jul 30, 10:42 am, "Justin" <h...@in.eswrote:
>>Thanks for the reply, but whe doing what you wrote, i get this very
strange
error:
String was not recognized as a valid DateTime

It means the value you're passing in isn't a valid DateTime. What is
vlgn equal to?


Jul 30 '07 #6
On Jul 30, 11:59 am, "Justin" <h...@in.eswrote:
"Larry Bud" <larrybud2...@yahoo.comschreef in berichtnews:11**********************@e16g2000pri.g ooglegroups.com...


"Jesse Houwing" <jesse.houw...@nospam-sogeti.nlschreef in
berichtnews:On**************@TK2MSFTNGP02.phx.gbl. ..
* Justin wrote, On 30-7-2007 16:11:
Hi,
this code updates a table with the new values with the event
RowUpdating
of a gridview.
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
GridView1.RowUpdating
Dim vlgn As Int16
vlgn = e.NewValues("vlg")
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=" & vlgn
This works.
Now i want to use parameters (without creating a stored procedure). I
tried this but fails:
SqlDataSource1.UpdateParameters.Add("vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=vlg"
Could somebody give me the right syntax for this?
Thanks
Justin
The parameter has a specific, unique name and usually starts with a '@'
sign:
SqlDataSource1.UpdateParameters.Add("@vlg", SqlDbType.SmallInt, vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=@vlg"
On Jul 30, 10:42 am, "Justin" <h...@in.eswrote:
Thanks for the reply, but whe doing what you wrote, i get this very
strange
error:
String was not recognized as a valid DateTime
It means the value you're passing in isn't a valid DateTime. What is
vlgn equal to?-
The value is a smallint (50). It has nothing to do with datetime.
Has it something to do with the fact i use the event "RowUpdating"?
Please post your reply at the bottom so the conversation follows a
logical flow...

Can you run your SQL statement Query Analyzer? If so, you need to
capture the SQL that's being generated from your app by using SQL
Profiler.

Jul 30 '07 #7
Ok, thanks, i'll try ...

"Larry Bud" <la**********@yahoo.comschreef in bericht
news:11**********************@m37g2000prh.googlegr oups.com...
On Jul 30, 11:59 am, "Justin" <h...@in.eswrote:
>"Larry Bud" <larrybud2...@yahoo.comschreef in
berichtnews:11**********************@e16g2000pri. googlegroups.com...


>"Jesse Houwing" <jesse.houw...@nospam-sogeti.nlschreef in
berichtnews:On**************@TK2MSFTNGP02.phx.gbl ...
>* Justin wrote, On 30-7-2007 16:11:
Hi,
>this code updates a table with the new values with the event
RowUpdating
of a gridview.
>Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e
As
System.Web.UI.WebControls.GridViewUpdateEventArgs ) Handles
GridView1.RowUpdating
>Dim vlgn As Int16
vlgn = e.NewValues("vlg")
>SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=" & vlgn
>This works.
Now i want to use parameters (without creating a stored procedure).
I
tried this but fails:
>SqlDataSource1.UpdateParameters.Add("vlg", SqlDbType.SmallInt,
vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=vlg"
>Could somebody give me the right syntax for this?
Thanks
Justin
The parameter has a specific, unique name and usually starts with a
'@'
sign:
SqlDataSource1.UpdateParameters.Add("@vlg", SqlDbType.SmallInt,
vlgn)
SqlDataSource1.UpdateCommand = "UPDATE mytable set vlg=@vlg"
On Jul 30, 10:42 am, "Justin" <h...@in.eswrote:
>Thanks for the reply, but whe doing what you wrote, i get this very
strange
error:
String was not recognized as a valid DateTime
It means the value you're passing in isn't a valid DateTime. What is
vlgn equal to?-
>The value is a smallint (50). It has nothing to do with datetime.
Has it something to do with the fact i use the event "RowUpdating"?

Please post your reply at the bottom so the conversation follows a
logical flow...

Can you run your SQL statement Query Analyzer? If so, you need to
capture the SQL that's being generated from your app by using SQL
Profiler.

Jul 30 '07 #8

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

Similar topics

2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
3
by: jkayne | last post by:
Can someone offer some insight of why parameters outside of those contained in a SqlDataSource <UpdateParameters> section would show up in a profiler trace? I'm using: <UpdateParameters>...
1
by: bill tie | last post by:
I'm exploring Microsoft sample code. This is a master/detail scenario with two SqlDataSources. The master table shows Northwind.Customers data. In the detail table, I can massage a row of data...
1
by: Phillip Ian | last post by:
I've got the following: <asp:ObjectDataSource ID="lu" runat="server" TypeName="cFactory" SelectMethod="GetLookup" UpdateMethod="UpdateLookup" DataObjectTypeName="cLookupItem">...
1
by: Islamegy® | last post by:
How could i pass a parmeter to objectDataSource.. objectDataSource1.UpdateParameters don't have "Value" Property, How could i set parameters value at runtime??
1
by: jkeel | last post by:
If I try to Update a record with the following code using a stored procedure I get an error: <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$...
2
by: info | last post by:
Hi guys. I have been thrown into the deep end. I don't know ASP, and with my C# development, I haven't used data aware controls. I am swimming OK so far (Image uploaded completed, XML/XSL menu...
3
by: mturner64 | last post by:
I am using Microsoft VWD 2008 express edition. I have linked an Access 2007 database to my asp.net application using a gridview control. On the webpage are four text boxes allowing a user to input...
0
by: Jeff | last post by:
hi asp.net 2.0 I have a GridView which when updating I get this error: DataBinding: 'System.Web.UI.WebControls.GridView' does not contain a property with the name 'Type'. Here is the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.