problem with updating table

M

Mark

Hi,

i try to update field 'name' (nvarchar(5) in sql server) of table 'mytable'.
This happens in event DetailsView1_ItemUpdating with my own code.
It works without parameters (i know, bad way) like this:
SqlDataSource1.UpdateCommand = "UPDATE mytable set name= '" & na & "'"

But when using parameters like here below, i get the error:
"Input string was not in a correct format"

Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles
DetailsView1.ItemUpdating
SqlDataSource1.UpdateCommand = "UPDATE mytable set name= @myname"
SqlDataSource1.UpdateParameters.Add("@myname", SqlDbType.NVarChar, na)
SqlDataSource1.Update()
End Sub

I don't see what's wrong here.
Thanks for help
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top