Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Converting Data Types

Author  Topic 

Iain Duthie
Starting Member

17 Posts

Posted - 2005-01-21 : 09:54:17
I am getting an error saying, "Syntax error converting the varchar value '1-10448-1' to a column of data type int." In the Sql table the data type is a varchar so I don't know why its trying to convert it to an int.

Cheers
Iain

chadmat
The Chadinator

1974 Posts

Posted - 2005-01-21 : 12:11:00
Can you post the code that is generating this error?

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-21 : 13:44:56
i'd check the datatypes of paramters used for stored procedure if you use them. that can be very easy to mess up...

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Iain Duthie
Starting Member

17 Posts

Posted - 2005-01-24 : 04:27:56
sqlCmd1.CommandText = "UPDATE manufact_table SET drawing_no = " + (TXTDnumber.Text) + " WHERE (drawing_no = " + TXTDrawing_no.Text + ")";

This is the code that generates the error. I can't see anything wrong with it. The problem seems to be that it doesn't like the number that is the TXTDrawing_no part because the number is 1-10448-1.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-24 : 05:44:36
then it needs to be like this:
"UPDATE manufact_table SET drawing_no = '" + (TXTDnumber.Text) + "' WHERE (drawing_no = '" + TXTDrawing_no.Text + "')";

note the ' around text.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Iain Duthie
Starting Member

17 Posts

Posted - 2005-01-24 : 06:07:28
I have tried putting the ' around text but the still gives the same error.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-24 : 07:23:49
drawing_no is varchar, right? it's not int.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Iain Duthie
Starting Member

17 Posts

Posted - 2005-01-24 : 09:47:04
Yes it's a varchar
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2005-01-24 : 13:21:45
Post the Table DDL. Also run profiler and capture the exact SQL that is being run (Or you can set a breakpoint in your code, and get the SQL String from the watch window).

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page

Iain Duthie
Starting Member

17 Posts

Posted - 2005-02-18 : 09:51:20
Thank you all for your I have managed to solve the problem I was having.

Cheers
Iain.
Go to Top of Page
   

- Advertisement -