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

Why doesn't this work?

Hi all,

I get a 'input string was not in a correct format' error on the second
line of code here. The sproc defines the '@quan5x7' as int.

sqlCmd.Parameters.Add("@quan5x7", SqlDbType.Int);
sqlCmd.Parameters[21].Value = Convert.ToInt32(cmbQuan5x7.Text);

The SqlDbType.Int is equal to System.Int32 correct?

Using C# Express and SQL 2005 Express. Thanks for any insight.

Jul 18 '07 #1
7 1357
Looch wrote:
Hi all,

I get a 'input string was not in a correct format' error on the second
line of code here. The sproc defines the '@quan5x7' as int.

sqlCmd.Parameters.Add("@quan5x7", SqlDbType.Int);
sqlCmd.Parameters[21].Value = Convert.ToInt32(cmbQuan5x7.Text);
The text of the control is a value that can not be converted to an int.
The SqlDbType.Int is equal to System.Int32 correct?
Yes.
Using C# Express and SQL 2005 Express. Thanks for any insight.

--
Göran Andersson
_____
http://www.guffa.com
Jul 18 '07 #2
Looch wrote:
Hi all,

I get a 'input string was not in a correct format' error on the second
line of code here. The sproc defines the '@quan5x7' as int.

sqlCmd.Parameters.Add("@quan5x7", SqlDbType.Int);
sqlCmd.Parameters[21].Value = Convert.ToInt32(cmbQuan5x7.Text);

The SqlDbType.Int is equal to System.Int32 correct?

Using C# Express and SQL 2005 Express. Thanks for any insight.
My initial guess is that cmbQuan5x7.Text does not contain a value that
can be converted to an int.
--
Tom Porterfield
Jul 18 '07 #3
On Wed, 18 Jul 2007 19:28:22 +0200, Looch <lu**********@yahoo.comwrote:
Hi all,

I get a 'input string was not in a correct format' error on the second
line of code here. The sproc defines the '@quan5x7' as int.

sqlCmd.Parameters.Add("@quan5x7", SqlDbType.Int);
sqlCmd.Parameters[21].Value = Convert.ToInt32(cmbQuan5x7.Text);

The SqlDbType.Int is equal to System.Int32 correct?

Using C# Express and SQL 2005 Express. Thanks for any insight.

I'm guessing the 21st SqlParameter isn't what you think it is, try

sqlCmd.Parameters["@quan5x7"].Value = Convert.ToInt32(cmbQuan5x7.Text);

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 18 '07 #4
Looch <lu**********@yahoo.comwrote:
I get a 'input string was not in a correct format' error on the second
line of code here. The sproc defines the '@quan5x7' as int.

sqlCmd.Parameters.Add("@quan5x7", SqlDbType.Int);
sqlCmd.Parameters[21].Value = Convert.ToInt32(cmbQuan5x7.Text);

The SqlDbType.Int is equal to System.Int32 correct?
Well, they're not the same type - but the chances are that the problem
is really that cmbQuan5x7.Text can't be parsed as an integer.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jul 18 '07 #5
Hi,

"Looch" <lu**********@yahoo.comwrote in message
news:11**********************@m37g2000prh.googlegr oups.com...
Hi all,

I get a 'input string was not in a correct format' error on the second
line of code here. The sproc defines the '@quan5x7' as int.

sqlCmd.Parameters.Add("@quan5x7", SqlDbType.Int);
sqlCmd.Parameters[21].Value = Convert.ToInt32(cmbQuan5x7.Text);

The SqlDbType.Int is equal to System.Int32 correct?
not the same, but you have a defined conversion.

The problem most probably is cause cmbQuan5x7.Text is not an integer value
Jul 18 '07 #6
Morten Wennevik [C# MVP] wrote:
On Wed, 18 Jul 2007 19:28:22 +0200, Looch <lu**********@yahoo.comwrote:
>Hi all,

I get a 'input string was not in a correct format' error on the second
line of code here. The sproc defines the '@quan5x7' as int.

sqlCmd.Parameters.Add("@quan5x7", SqlDbType.Int);
sqlCmd.Parameters[21].Value = Convert.ToInt32(cmbQuan5x7.Text);

The SqlDbType.Int is equal to System.Int32 correct?

Using C# Express and SQL 2005 Express. Thanks for any insight.


I'm guessing the 21st SqlParameter isn't what you think it is, try

sqlCmd.Parameters["@quan5x7"].Value = Convert.ToInt32(cmbQuan5x7.Text);
Did you mean 22nd?

Cheers,

Cliff

--

Have you ever noticed that if something is advertised as 'amusing' or
'hilarious', it usually isn't?
Jul 18 '07 #7
On Wed, 18 Jul 2007 23:25:39 +0200, Enkidu <en********@com.cliffp.comwrote:
Morten Wennevik [C# MVP] wrote:
>On Wed, 18 Jul 2007 19:28:22 +0200, Looch <lu**********@yahoo.comwrote:
>>Hi all,

I get a 'input string was not in a correct format' error on the second
line of code here. The sproc defines the '@quan5x7' as int.

sqlCmd.Parameters.Add("@quan5x7", SqlDbType.Int);
sqlCmd.Parameters[21].Value = Convert.ToInt32(cmbQuan5x7.Text);

The SqlDbType.Int is equal to System.Int32 correct?

Using C# Express and SQL 2005 Express. Thanks for any insight.


I'm guessing the 21st SqlParameter isn't what you think it is, try

sqlCmd.Parameters["@quan5x7"].Value = Convert.ToInt32(cmbQuan5x7.Text);
Did you mean 22nd?

Cheers,

Cliff
Ah, a bit hasty there :) Anyhow, the most likely cause for his error isprobably empty Text property or a Text property containing something other than an integer value.

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 18 '07 #8

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

Similar topics

7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
39
by: Mark Johnson | last post by:
It doesn't seem possible. But would the following also seem a violation of the general notions behind css? You have a DIV, say asociated with class, 'topdiv'. Inside of that you have an anchor...
3
by: Matt | last post by:
I want to know if readOnly attribute doesn't work for drop down list? If I try disabled attribute, it works fine for drop down list. When I try text box, it works fine for both disabled and...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
4
by: bbp | last post by:
Hello, In an ASPX page I have a "Quit" button which make a simple redirect in code-behind. This button doesn't work no more since (I think) I moved from the framework 1.0 to 1.1 and it doesn't...
3
by: Dave Moore | last post by:
Hi All, Ok, here's my problem. I want to open a file and process its contents. However, because it is possible that the file may not exist, I also want to check whether the file() function is...
10
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET...
6
by: Johnny Jörgensen | last post by:
I've got a usercontrol derived from a normal ComboBox that contains some special formatting code. On my main form I've got a lot of my custom comboboxes. I discovered a bug in the derived...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
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
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.