用OleDb 类读取access数据库有如下问题:
读取 access数据库的 dataTable 的函数如下:
Private Shared Function GetDataTableOle(ByRef ATable As DataTable, ByVal queryString As String, ByRef errStr As String) As Boolean
Dim bErr As Boolean = False
Dim adapter As OleDbDataAdapter ' SqlDataAdapter
Using connection As New OleDbConnection(getConnString) ' SqlConnection(getConnString)
adapter = New OleDbDataAdapter
Try
adapter.SelectCommand = New OleDbCommand( _
queryString, connection)
If Not IsNothing(ATable) Then
ATable.Dispose()
ATable = Nothing
End If
ATable = New DataTable
adapter.Fill(ATable) '此句有错
Catch e As Exception
bErr = True
errStr = e.Message
ATable.Dispose()
End Try
End Using
adapter.Dispose()
Return Not bErr
End Function其中 adapter.Fill(ATable) 句运行时出错:参数类型错误.
可是查看SDK文挡 adapter.Fill()显示它接受DataTable参数呀
其它代码数据库应没有问题.
请问问题出在哪里,如何解决呀?
读取 access数据库的 dataTable 的函数如下:
Private Shared Function GetDataTableOle(ByRef ATable As DataTable, ByVal queryString As String, ByRef errStr As String) As Boolean
Dim bErr As Boolean = False
Dim adapter As OleDbDataAdapter ' SqlDataAdapter
Using connection As New OleDbConnection(getConnString) ' SqlConnection(getConnString)
adapter = New OleDbDataAdapter
Try
adapter.SelectCommand = New OleDbCommand( _
queryString, connection)
If Not IsNothing(ATable) Then
ATable.Dispose()
ATable = Nothing
End If
ATable = New DataTable
adapter.Fill(ATable) '此句有错
Catch e As Exception
bErr = True
errStr = e.Message
ATable.Dispose()
End Try
End Using
adapter.Dispose()
Return Not bErr
End Function其中 adapter.Fill(ATable) 句运行时出错:参数类型错误.
可是查看SDK文挡 adapter.Fill()显示它接受DataTable参数呀
其它代码数据库应没有问题.
请问问题出在哪里,如何解决呀?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货