School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,137 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,904 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 Rate Topic: -----

#1 ajeebaj  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 3
  • Joined: 26-May 09


Dream Kudos: 0

Posted 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
Was This Post Helpful? 0
  • +
  • -


#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • Icon
  • View blog
  • Group: Expert w/DIC++
  • Posts: 2,232
  • Joined: 21-March 08


Dream Kudos: 600

Expert In: .NET

Posted 26 May 2009 - 03:36 AM

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

Was This Post Helpful? 0
  • +
  • -

#3 noorahmad  Icon User is offline

  • Author
  • Icon
  • View blog
  • Group: Author w/DIC++
  • Posts: 2,198
  • Joined: 12-March 09


Dream Kudos: 1600

Posted 26 May 2009 - 03:37 AM

:code:
try to use
Convert.ToDouble(txt.Text)


~Noor Ahmad~

This post has been edited by noorahmad: 26 May 2009 - 03:40 AM

Was This Post Helpful? 0
  • +
  • -

#4 ajeebaj  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 3
  • Joined: 26-May 09


Dream Kudos: 0

Posted 26 May 2009 - 03:47 AM

View Postnoorahmad, on 26 May, 2009 - 03:37 AM, said:

:code:
try to use
Convert.ToDouble(txt.Text)


~Noor Ahmad~


I tried Conver.ToDouble(txt.Text) it error message like
"Cannot convert double to float"
Was This Post Helpful? 0
  • +
  • -

#5 noorahmad  Icon User is offline

  • Author
  • Icon
  • View blog
  • Group: Author w/DIC++
  • Posts: 2,198
  • Joined: 12-March 09


Dream Kudos: 1600

Posted 26 May 2009 - 03:55 AM

try this
MessageBox.Show(Convert.ToDecimal(textBox1.Text).ToString());

Was This Post Helpful? 0
  • +
  • -

#6 ajeebaj  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 3
  • Joined: 26-May 09


Dream Kudos: 0

Posted 26 May 2009 - 04:01 AM

View Postajeebaj, on 26 May, 2009 - 03:23 AM, said:

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
Was This Post Helpful? 0
  • +
  • -

#7 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • Icon
  • View blog
  • Group: Expert w/DIC++
  • Posts: 2,232
  • Joined: 21-March 08


Dream Kudos: 600

Expert In: .NET

Posted 26 May 2009 - 04:44 AM

and this is the main reason I stay away from using Float in SQL. I would suggest using the decimal datatype.
Was This Post Helpful? 0
  • +
  • -

#8 seser  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 8
  • Joined: 20-April 09


Dream Kudos: 0

Posted 26 May 2009 - 05:23 AM

float = Single

you can use either

Convert.ToSingle("");

float.Parse("");


Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

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

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month