Click here to Skip to main content
16,020,677 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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

C#
  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();

        }

// the other part is

     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
Posted
Comments
[no name] 29-Apr-15 5:18am    
Try to pass the values as params
ost3z 29-Apr-15 6:19am    
how it be done
[no name] 29-Apr-15 6:33am    
cmd.Parameters.Add("@Value1", SqlDbType.Float).Value = Convert.ToDouble(Re_price)
ost3z 29-Apr-15 8:12am    
i have gridview which have the data which i need to pass how can i pass them using params how will be
dt.cloumns.add("".oldbetype.varchar), and so on or how will be done

1 solution

thanks for all i have solved it using params
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900