在C#中使用的toString()获得大整数指数值 [英] Using toString() in C# get exponential value for big Integer
问题描述
我有脚本任务转变对我的SSIS包。 基本上我用写纸条的任务数据(SQL查询)到txt文件。
I have script task transformation on my SSIS package. Basically i write data(sql query) to txt file using scrip task.
这片code sw.Write(DR(I)的ToString())
无法把这个值 11398069
正常。我想我需要使用 bigInt.ToString()
,但它与任何价值的工作。
11398069 - 后出口TXT显示该值 1.13981e + 007
而不是 11398069
让我知道。
this piece of code sw.Write(dr(i).ToString())
couldn't convert this value 11398069
properly. I think i need to use bigInt.ToString()
but does it work with any value.
11398069 -- after export txt shows this value as 1.13981e+007
instead of 11398069
Let me know.
下面是code以下。
sw.Write(sw.NewLine)
For Each dr As DataRow In dt.Rows
sw.Write("5|")
For i As Integer = 0 To iColCount - 1
If Not Convert.IsDBNull(dr(i)) Then
**sw.Write(dr(i).ToString())**
End If
If i < iColCount - 1 Then
sw.Write("|")
End If
Next
sw.Write(sw.NewLine)
Next
值可能是真的什么。 例如(样品值)。 120 120.09290 1.23443 ABC ZZZZZZZ 11398069 - 后出口TXT显示该值作为1.13981e + 007,而不是11398069
Values could be really anything. For instance(Sample values). 120 120.09290 1.23443 ABC ZZZZZZZ 11398069 -- after export txt shows this value as 1.13981e+007 instead of 11398069
让我知道如何处理这种
推荐答案
在SQL Server BIGINT
类型映射到.NET System.Int64
或VB 龙
键入。这应该这样做,如果表列是一个真正的 BIGINT
:
The SQL Server bigint
type maps to the .NET System.Int64
or VB Long
type. This should do it if the table column is really a bigint
:
DirectCast(dr(i), Long).ToString()
您也说这个数值可以是任何东西。举个例子,你写的ABC。是您的表列真正类型为 BIGINT
或者是一个 VARCHAR
或 NVARCHAR
列?在后一种情况下,它可能只包含格式化为值 1.13981e + 007
。
You also say that the values could be anything. As an example you write "ABC". Is your table column really typed as bigint
or is it a VARCHAR
or NVARCHAR
column? In the latter case it could just contain the value formatted as 1.13981e+007
.
另一个问题是,什么是软件
?难道说在写
命令执行一些不必要的格式?
Another question is, what is sw
? Could it be that the Write
command performs some kind of unwanted formatting?
如果博士(我)
返回双击
则可以formaatted在exponeial格式为好。这将有助于:
If dr(i)
returns a Double
then it could be formaatted in the exponeial format as well. This would help:
DirectCast(dr(i), Double).ToString("0")
更新
您可能必须做一些像
If Not dr.IsDBNull(i) Then
Dim s As String
If dr.GetFieldType(i) Is GetType(Double) Then
s = dr.GetDouble(i).ToString("0")
Else
s = dr(i).ToString()
End If
sw.Write(s)
End If
这真的取决于非常列被错误格式化的类型。该号码被格式化为指数格式的事实是强烈暗示数的类型(SQL类型,尤其是VB类型被映射到的)其实不是一个整数类型(Integer,长),但某些十进制或者浮点类型(单人,双人,十进制)。非常存储号码可能没有小数和为整数,但这并不能使一个整数键入
设置在 sw.Write(DR(I)的ToString())
行设置一个断点,并检查通过返回运行时类型博士(我)
。或插入行
Set a breakpoint on the sw.Write(dr(i).ToString())
line and inspect the runtime type returned by dr(i)
. Or insert the line
System.Diagnostics.Debug.WriteLine( _
String.Format("col({0}) = {1}", i, dr.GetFieldType(i)))
和显示输出继电器窗口(菜单的调试>窗口>输出的)。
And display the Ouput Window (menu Debug > Windows > Output).
这篇关于在C#中使用的toString()获得大整数指数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!