C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 306,832 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,757 people online right now. Registration is fast and FREE... Join Now!




How to pass float data type into sql server there is no toFloat functi

 

How to pass float data type into sql server there is no toFloat functi

ajeebaj

26 May, 2009 - 03:23 AM
Post #1

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 3

How to pass float datatype into sql server. My sqlserver data type is float and function data type also float. I am trying pass text box values to that
that function it shows error like input string was not currect format

User is offlineProfile CardPM
+Quote Post


eclipsed4utoo

RE: How To Pass Float Data Type Into Sql Server There Is No ToFloat Functi

26 May, 2009 - 03:36 AM
Post #2

Not Your Ordinary Programmer
Group Icon

Joined: 21 Mar, 2008
Posts: 1,846



Thanked: 205 times
Dream Kudos: 500
Expert In: .NET

My Contributions
you need to convert the value in the textbox to a double. and also make sure it's an actual number.

This post has been edited by eclipsed4utoo: 26 May, 2009 - 03:37 AM
User is offlineProfile CardPM
+Quote Post

noorahmad

RE: How To Pass Float Data Type Into Sql Server There Is No ToFloat Functi

26 May, 2009 - 03:37 AM
Post #3

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,086



Thanked: 142 times
Dream Kudos: 1350
My Contributions
code.gif
try to use
CODE
Convert.ToDouble(txt.Text)


~Noor Ahmad~

This post has been edited by noorahmad: 26 May, 2009 - 03:40 AM
User is online!Profile CardPM
+Quote Post

ajeebaj

RE: How To Pass Float Data Type Into Sql Server There Is No ToFloat Functi

26 May, 2009 - 03:47 AM
Post #4

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 3

QUOTE(noorahmad @ 26 May, 2009 - 03:37 AM) *

code.gif
try to use
CODE
Convert.ToDouble(txt.Text)


~Noor Ahmad~


I tried Conver.ToDouble(txt.Text) it error message like
"Cannot convert double to float"
User is offlineProfile CardPM
+Quote Post

noorahmad

RE: How To Pass Float Data Type Into Sql Server There Is No ToFloat Functi

26 May, 2009 - 03:55 AM
Post #5

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,086



Thanked: 142 times
Dream Kudos: 1350
My Contributions
try this
CODE
MessageBox.Show(Convert.ToDecimal(textBox1.Text).ToString());

User is online!Profile CardPM
+Quote Post

ajeebaj

RE: How To Pass Float Data Type Into Sql Server There Is No ToFloat Functi

26 May, 2009 - 04:01 AM
Post #6

New D.I.C Head
*

Joined: 26 May, 2009
Posts: 3

QUOTE(ajeebaj @ 26 May, 2009 - 03:23 AM) *

How to pass float datatype into sql server. My sqlserver data type is float and function data type also float. I am trying pass text box values to that
that function it shows error like input string was not currect format


(float) Convert.ToDouble(txt.text) will work
User is offlineProfile CardPM
+Quote Post

eclipsed4utoo

RE: How To Pass Float Data Type Into Sql Server There Is No ToFloat Functi

26 May, 2009 - 04:44 AM
Post #7

Not Your Ordinary Programmer
Group Icon

Joined: 21 Mar, 2008
Posts: 1,846



Thanked: 205 times
Dream Kudos: 500
Expert In: .NET

My Contributions
and this is the main reason I stay away from using Float in SQL. I would suggest using the decimal datatype.
User is offlineProfile CardPM
+Quote Post

seser

RE: How To Pass Float Data Type Into Sql Server There Is No ToFloat Functi

26 May, 2009 - 05:23 AM
Post #8

New D.I.C Head
*

Joined: 20 Apr, 2009
Posts: 8



Thanked: 4 times
My Contributions
float = Single

you can use either

CODE

Convert.ToSingle("");

float.Parse("");

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/20/09 10:47PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month