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

Failed to convert parameter value from a String to a Decimal

44
Hi

In sql server 2005 I have a column as

GraduationYear Decimal(4,0). In asp.net I used the coding for that as

SqlParameter GraduationYear = new SqlParameter("@GraduationYear", SqlDbType.Decimal);
GraduationYear.Value = GYTextBox.Text;

but while running I got error as

Failed to convert parameter value from a String to a Decimal.
Jul 7 '08 #1
4 10235
Curtis Rutland
3,256 Expert 2GB
Obviously there is a conversion error. Try
GraduationYear.Value = Convert.ToDecimal(GYTextBox.Text);
Jul 7 '08 #2
sweatha
44
Obviously there is a conversion error. Try
GraduationYear.Value = Convert.ToDecimal(GYTextBox.Text);
Hi

I tried that but it is still showing error:

Input string was not in a correct format.
Jul 7 '08 #3
Hi ,

Your error may be because you have not specified the size of the datatype decimal(4,0)..... Try passing the size with the parameters u have given..

ie,
SqlParameter GraduationYear = new SqlParameter("@GraduationYear", SqlDbType.Decimal,(4,0));


Arun
Jul 7 '08 #4
nmsreddi
366 256MB
Hello

the error what you get is a compile time or run time error ,

most of the you will get "Input string not in a correct " error if the input is null or empty just check the text box value what you are passing is correct or not.
Jul 7 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: KB | last post by:
Hi guys, In my DataGrid I have a column that displays decimal values as currency ( I set the Data Formatting expression of that column to {0:C}). So the actual string displayed in the grid looks...
5
by: Mika M | last post by:
Hi! I've made little code to convert string into hex string... Public ReadOnly Property ToHexString(ByVal text As String) As String Get Dim arrBytes As Integer() = CharsToBytes(text) Dim sb...
0
by: Chris Crowe [MVP 1997 -> 2006] | last post by:
I am having major problems using GetStoredProcCommand and using Parameters in the same function call in the latest builds of the Enterprise Library Data. The error I get is : Failed to...
10
by: Zontar | last post by:
I'm trying to improve performance on a query, and I was wondering if this is possible in Access. Let's say I have a table with one text column and one row. In that column, I have a field name...
2
by: mikejacobz | last post by:
Hi, I am using the Enterprise Application Blocks (Data Access Application Block 2005) and all I want to do is pass in a date as a parameter to a Stored procedure. e.g private void...
0
by: weird0 | last post by:
Here is the code for executing stored procedure ExecuteSP() , and object that sets all its parameters in other functions and the stored procedure. I think it has something to do with db datatypes...
3
by: balajius | last post by:
I am using VS2008 with asp.net 3.5 and enterprise library 4.1. I am getting the following error when I try to connect to database. "Failed to convert parameter value from a SqlParameter to a String"...
0
by: androm | last post by:
when i run my code i get this error message "Failed to convert parameter value from a SqlParameter to a DateTime." & i couldn't find what is wrong..... here's my code protected void...
4
by: dougancil | last post by:
I'm trying to pass values in a SessionState from one page to another and then post them to a SQL database. When I click on the submit button on my submit page, I get this error: Failed to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.