C#选择查询Varchar科学记数法问题

时间:2017-10-25 08:19:24

标签: c# sql

我有15万份产品记录。产品有部分没有像662750944011590这样的长数,有些有009093j

但是长期没有被转换为科学记数法,如6.62751E + 14。我在gridview中使用partno作为自动完成。

用户无法理解科学记数法。所以基本上我想把数字作为字符串。

enter image description here

我曾经使用过csv的d​​tswizard到sql server。在CSV中,它是长号,但在SQL中,它是作为科学记数法导入的。不知道为什么?

SQL列的类型是Varchar(Max)。

Retriving和添加到AutoCompleteStringCollection数据网格的代码是:

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());
            }

1 个答案:

答案 0 :(得分:0)

这样做

<html>
     <body>
        <div style ="width:20px; height:30px; border:1px solid black; overflow-x:scroll; overflow-y:hidden; white-space:nowrap;">
            <!-- various of text here that can makes it go out the border-->
        </div>  
     </body>
</html>