alaa

alaa

  • NA
  • 166
  • 84.9k

field type change in insert

Apr 29 2015 2:42 AM
hi everyone i have database access where i have atable which gets its data from gridview 3 of field are number and accept double when i pass value the  fields type get change into text
whats the wrong that make happen this is my code

   public void Addrep(string ReName, double Reprice, double Retotal, double Recount)
        {
 
            String str = " INSERT INTO Report ( Re_Name, Re_price, Re_total, Re_count ) values ('" + ReName + "','" + Reprice + "','" + Retotal + "','" + Recount + "' )";

            OpenCnn();

            //3- Open command option - cnn parameter is imporant
            OleDbCommand cmd = new OleDbCommand(str, cnn);
            cmd.ExecuteNonQuery();
            //5 close connection
            CloseCnn();

        }


     if (RowsCount != 0 || RowsCount != null)
                {
                    repo.DeleteRe();

                    for (int i = 0; i < RowsCount; i++)
                    {
                        //this.dgvsell.Rows[i].Cells[2].Value.ToString()
                        repo.Insert(this.dgvsell[2, i].Value.ToString(),
                            Convert.ToDouble(dgvsell[4, i].Value),
                            Convert.ToDouble(dgvsell[5, i].Value),
                            Convert.ToDouble(dgvsell[6, i].Value));
                    }
                   
                }

and my fields are Re_Name  text, Re_price double, Re_total double, Re_count number

in insert it changed automatically into
Re_Name  text, Re_price text, Re_total text, Re_count text what is the best soulation for that problem

Answers (2)