0

I have 150 000 records of products. Products has partno some has long number like 662750944011590 and some has 009093j

But long no is convert to scientific notation like 6.62751E+14. I am using partno as autocomplete inside gridview.

User can't understand scientific notation. So basically i want to get number as string.

enter image description here

I had used dtswizard from csv to sql server. In CSV it is long number but in SQL it is imported as scientific notation. Don't know why?

Type of SQL column is Varchar(Max).

Code of Retriving and adding to AutoCompleteStringCollection datagrid is :

using (SqlConnection connection = new SqlConnection(connectionstring))
            {
                SqlDataAdapter adapter = new SqlDataAdapter();
                adapter.SelectCommand = new SqlCommand("select PartNo,PartDescription,HSN,MRP,GST from products_data", connection);
                adapter.Fill(dataset);

                Dataset products_tbl = dataset.Tables[0];
                //data is AutoCompleteStringCollection object
                for (int i = 0; i < products_tbl.Rows.Count; i++)
                    data.Add(products_tbl.Rows[i]["PartNo"].ToString());
            }
James Z
  • 12,209
  • 10
  • 24
  • 44
Naitik Kundalia
  • 199
  • 1
  • 1
  • 19

1 Answers1

0

Do like this

using (SqlConnection connection = new SqlConnection(connectionstring))
        {
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand("select PartNo,PartDescription,HSN,MRP,GST from products_data", connection);
            adapter.Fill(dataset);

            Dataset products_tbl = dataset.Tables[0];
            //data is AutoCompleteStringCollection object
            for (int i = 0; i < products_tbl.Rows.Count; i++)
                 //You can change the datatype from Decimal to  whatever you want string or etc
                       Decimal h2 = 0;
                      Decimal.TryParse(products_tbl.Rows[i]["PartNo"].ToString(), out h2);
                      data.Add(h2);
        }
  • It will not work if i convert to string and then fire select query where partno = 662750944011590 then it will not work because it is in scientific notation. So i want sql treat it as string instead of numbers – Naitik Kundalia Oct 25 '17 at 08:55
  • what do you want a number convert to string ? please show your desired output. –  Oct 25 '17 at 08:57
  • First Retrive ProductNo. It will be filled then fire sql to retrive all other column of that ProductNo.Then whole grid will be saved to other table. So yes i want sql treat number as string. I don't want conversion at software side because i have to convert each time when i need it. – Naitik Kundalia Oct 25 '17 at 09:09