-1
private void btn_update_Click(object sender, EventArgs e)
{
    decimal id = decimal.Parse(txt_ID.Text);
    string name = txt_name.Text;
    double agg = double.Parse(txt_aggregate.Text); 

    //string cmd = "update Student set Aggregate=" + "'" + aggregate + "'" + " where ID:
    string cmd = "udate student set Agrregate=@aggreagte where Id=@id ";
    command = new Sq1Command(cmd,con); 

    //register
    command.Parameters.Add("@aggregate",SqlDbType.Real);
    command.Parameters.Add("@id",SqlDbType.Decima1,10); 

    //submit 

    command.Parameters["@id"].Value = txt_ID.Text;
    // float agg=float.Parse(txt_aggregate.Text);
    command.Parameters["@aggregate"] = agg; 

    // DisplayGrid(cmd);I 

How do I convert text number to real in to store value in database?

SamWhan
  • 8,296
  • 1
  • 18
  • 45
  • 2
    google? "Convert text to number c#" for example. You have to show what you´ve tried so far to get some help. You can´t expect the users here to write your code. – MakePeaceGreatAgain Jun 20 '16 at 11:30
  • Possible duplicate of [Convert textbox text to integer](http://stackoverflow.com/questions/3548875/convert-textbox-text-to-integer) – Donovan Solms Jun 20 '16 at 12:00

1 Answers1

0

As HimBromBeere said, showing what you have done/tried so far will help to direct you tho the right solution.

But if what you are tying to convert a string to number(eg.int) you could use

int.Parse("10") or int.TryParse("10")

For the differences between the two methods and more details, refer to msdn documentations here

..If the string is not in a valid format, Parse throws an exception whereas TryParse returns false.

Community
  • 1
  • 1
iAM
  • 1,365
  • 15
  • 25
  • I have written in code variable agg is parsed int to double but while storing in data base I have stored in real valued data type. so I got error not implicitly converting to sql data type!!!!!!!!!!!!!!! – kunal pandit Jun 21 '16 at 13:30