Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > question about UpdateParameters.Add

Reply
Thread Tools

question about UpdateParameters.Add

 
 
Justin
Guest
Posts: n/a
 
      07-30-2007
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


 
Reply With Quote
 
 
 
 
Jesse Houwing
Guest
Posts: n/a
 
      07-30-2007
* 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
 
Reply With Quote
 
 
 
 
Justin
Guest
Posts: n/a
 
      07-30-2007
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
>* 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



 
Reply With Quote
 
Larry Bud
Guest
Posts: n/a
 
      07-30-2007

>
> "Jesse Houwing" <(E-Mail Removed)> schreef in berichtnews:(E-Mail Removed). ..
>
>
>
> >* 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" <(E-Mail Removed)> wrote:

> 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?

 
Reply With Quote
 
Justin
Guest
Posts: n/a
 
      07-30-2007
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) oups.com...
>
>>
>> "Jesse Houwing" <(E-Mail Removed)> schreef in
>> berichtnews:(E-Mail Removed). ..
>>
>>
>>
>> >* 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" <(E-Mail Removed)> wrote:
>
>> 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?
>



 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      07-30-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> schreef in bericht
> news:(E-Mail Removed) oups.com...
>>
>>>
>>> "Jesse Houwing" <(E-Mail Removed)> schreef in
>>> berichtnews:(E-Mail Removed). ..
>>>
>>>
>>>
>>> >* 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" <(E-Mail Removed)> wrote:
>>
>>> 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?
>>

>
>



 
Reply With Quote
 
Larry Bud
Guest
Posts: n/a
 
      07-30-2007
On Jul 30, 11:59 am, "Justin" <(E-Mail Removed)> wrote:
> "Larry Bud" <(E-Mail Removed)> schreef in berichtnews:(E-Mail Removed) ooglegroups.com...
>
>
>
>
>
> >> "Jesse Houwing" <(E-Mail Removed)> schreef in
> >> berichtnews:(E-Mail Removed). ..

>
> >> >* 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" <(E-Mail Removed)> wrote:

>
> >> 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.

 
Reply With Quote
 
Justin
Guest
Posts: n/a
 
      07-30-2007
Ok, thanks, i'll try ...

"Larry Bud" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed) oups.com...
> On Jul 30, 11:59 am, "Justin" <(E-Mail Removed)> wrote:
>> "Larry Bud" <(E-Mail Removed)> schreef in
>> berichtnews:(E-Mail Removed) ooglegroups.com...
>>
>>
>>
>>
>>
>> >> "Jesse Houwing" <(E-Mail Removed)> schreef in
>> >> berichtnews:(E-Mail Removed). ..

>>
>> >> >* 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" <(E-Mail Removed)> wrote:

>>
>> >> 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.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments