我在 Visual Studio 2005 中使用 oledbdataadapter 加载 CSV 文件。我遇到的问题是,如果任何给定字段的第一行的值为 0,则 oledbdataadapter 会将此字段转换为整数。它将所有后续值四舍五入为一个整数,去除小数点。作为测试,我用记事本手动打开 csv 并将第一行更改为 0.0 而不是仅 0,然后文件正确打开,使该字段成为双倍。打开 CSV 和格式字段加倍的正确方法是什么?
这是打开代码:
Sub LoadDB2Graph(ByVal DaFilename As String)
Dim DaTable As String
Try
MyDataAdapter.Dispose()
dsPressScope.Tables.Clear()
Catch e1 As Exception
End Try
MySelectCommand.CommandText = "SELECT * FROM [" & DaFilename & "] WHERE [Time] <> 0"
MyDataAdapter.SelectCommand = MySelectCommand
Try
Call DeleteTestLine(1)
Call DeleteTestLine(2)
DaTable = Replace(DaFilename, ".", "_")
MyDataAdapter.Fill(dsPressScope, DaTable)
dgPressScope.DataSource = dsPressScope
dgPressScope.DataMember = DaTable
dgPressScope.Refresh()
ZedGraph.GraphPane.CurveList.Clear()
InitializeTestLines()
ZedGraph.GraphPane.Title.Text = DBDirectory & DaFilename
ZedGraph.GraphPane.AxisChange()
tabMain.SelectTab("tbSelectPens")
Me.Text = "Press Scope - " & DBDirectory & DaFilename
Catch e1 As Exception
MessageBox.Show("Load Failed")
End Try
LoadPens2List()
End Sub