473,387 Members | 2,436 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,387 software developers and data experts.

Error Input string was not in a correct format

I am a bit baffled on this error. A windows app written in C# is
attempting to execute the following query:

SELECT *
FROM Employee
WHERE (Name LIKE '%' + @PARAM1 + '%') AND (Name LIKE '%' + @PARAM2
+ '%') AND (Company LIKE '%' + @PARAM3 + '%')

I am getting the following error - "Input string was not in a correct
format."

Nov 9 '07 #1
2 1763
Jose,
I'm not sure this is really a C# language group question, but--
The SQL statement you show would be fine if it was inside a stored procedure
and the @PARAMxx parameter variables were sproc input parameters.

However if this is, instead, an inline string concatenation in a block of C#
code, it is very wrong. You should be using a parameterized query in which
case it would look more like the following:

string strSQL=@"SELECT * FROM Employee WHERE (Name LIKE '%' + @PARAM1 + '%')
AND (Name LIKE '%' + @PARAM2 + '%') AND (Company LIKE '%' + @PARAM3 + '%')"

then,
cmd.Parameters.AddWithValue("@PARAM1", txtBoxParam1.Text ); // etc.

Hope that helps.

-- Peter
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Jose Oliver" wrote:
I am a bit baffled on this error. A windows app written in C# is
attempting to execute the following query:

SELECT *
FROM Employee
WHERE (Name LIKE '%' + @PARAM1 + '%') AND (Name LIKE '%' + @PARAM2
+ '%') AND (Company LIKE '%' + @PARAM3 + '%')

I am getting the following error - "Input string was not in a correct
format."

Nov 9 '07 #2
Hi,

Please clarify if this is ni C# or the actual query being executed in SQL

If you are concatenating the values in C# maybe you have a ' character in
one of the parameters.

In any case post the piece of code (C#) where you are getting the error.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Jose Oliver" <jo*********@hotmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
>I am a bit baffled on this error. A windows app written in C# is
attempting to execute the following query:

SELECT *
FROM Employee
WHERE (Name LIKE '%' + @PARAM1 + '%') AND (Name LIKE '%' + @PARAM2
+ '%') AND (Company LIKE '%' + @PARAM3 + '%')

I am getting the following error - "Input string was not in a correct
format."

Nov 9 '07 #3

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

Similar topics

5
by: hpy_awad | last post by:
I wrote that example from a book and there is en error in the display module that it does not showing all the records are entered in the input module. I traced with some printf statments without...
2
by: Rob Meade | last post by:
Hi all, I have a webform containing about 9 web user controls, these primarily are just html in a control thats used as the template etc.. A colleague has given me another control for our...
3
by: Bruce D | last post by:
I'm new to .NET and I have a error that is coming up but it's not telling me where the error is coming from (no file). Is that because I'm doing something wrong...or is it a type of error that has...
1
by: amitbadgi | last post by:
Welcome back amitbadgi | Logout | Faq Knowledge Discovery Keys COMPUTER PROGRAMMING, DATA MINING, STATISTICS, ARTIFICIAL INTELLIGENCE * Settings * Photos * Lists * MVPs * Forums * Blogs
3
by: Howard | last post by:
A non-integer value is entered as student id /grades.aspx?studentid=1283128sdf Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the...
8
by: WhiteWizard | last post by:
Have we got a STRANGE one going here. We converted from 1.1 to 2.0 about 2 weeks ago and this has been a problem since then...but only on SOME machines in our development group. The application...
0
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
0
by: Paul | last post by:
In GridView if I make the CommandArgument of a link button a string created from something like myGuid.ToString() the RowCommand handler dies with an error I can't track down. The only thing I know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.