7 Replies - 6969 Views - Last Post: 26 May 2009 - 06:23 AM Rate Topic: -----

#1 ajeebaj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-May 09

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

Posted 26 May 2009 - 04: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
Is This A Good Question/Topic? 0
  • +

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

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

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

Posted 26 May 2009 - 04: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 - 04:37 AM

Was This Post Helpful? 0
  • +
  • -

#3 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

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

Posted 26 May 2009 - 04:37 AM

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


~Noor Ahmad~

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

Was This Post Helpful? 0
  • +
  • -

#4 ajeebaj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-May 09

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

Posted 26 May 2009 - 04: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

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

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

Posted 26 May 2009 - 04: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

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-May 09

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

Posted 26 May 2009 - 05: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
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

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

Posted 26 May 2009 - 05: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

Reputation: 4
  • View blog
  • Posts: 8
  • Joined: 20-April 09

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

Posted 26 May 2009 - 06:23 AM

float = Single

you can use either

Convert.ToSingle("");

float.Parse("");


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1