Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2005 > SQL Server 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 2nd, 2007, 03:31 PM
Friend of Wrox
 
Join Date: Apr 2006
Location: , , .
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with Updating a table

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.DetailsViewUpdateEventAr gs) 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



Reply With Quote
  #2 (permalink)  
Old August 4th, 2007, 02:47 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: noida, UP, India.
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

This line is incorrect:-
SqlDataSource1.UpdateParameters.Add("@myname", SqlDbType.NVarChar, na)

You should write it as follow:-
SqlDataSource1.UpdateParameters.Add("@myname", System.TypeCode.String, na)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating one table with data from another table dirtdog22 Access VBA 1 January 21st, 2008 04:41 PM
Updating Table gregalb SQL Server 2000 1 June 2nd, 2007 04:39 PM
ch 6 commit.php problem updating movie table statusquo BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 May 2nd, 2005 10:02 PM
Updating table Hudson40 Access VBA 6 March 23rd, 2005 12:07 PM
updating table markhardiman Classic ASP Databases 2 September 29th, 2004 12:35 PM



All times are GMT -4. The time now is 04:43 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.