“提供程序无法确定 String 值。例如,该行刚刚创建,未提供 String 列的默认值,并且使用者尚未设置新 String 值。”
这是代码:
Function ReadExcel(ByVal FileName As String, ByVal SheetName As String)
Dim s$ = ("Provider=Microsoft.ACE.OLEDB.12.0;" & "data source=") & FileName & ";Extended Properties='Excel 12.0; HDR=NO; IMEX=1'"
Dim ss$ = String.Format("SELECT * FROM [{0}$]", SheetName)
Dim OleDbConnection As New OleDb.OleDbConnection(s)
OleDbConnection.Open()
Dim OleDbDataAdapter As New OleDb.OleDbDataAdapter(ss, OleDbConnection)
Dim DataTable = New DataTable
OleDbDataAdapter.Fill(DataTable)
OleDbDataAdapter.Dispose()
OleDbConnection.Close()
Return DataTable
End Function
跳错的是这一句:
OleDbDataAdapter.Fill(DataTable)
[此贴子已经被作者于2019-9-2 16:00编辑过]