0

我正在尝试使用 .NET 3.5 中的 OracleConnection 建立与远程 oracle 数据库的连接(我知道它已在更高版本的 .NET 中被弃用)。为什么 Visual Studio 不能识别语句 myAdapter.fill(mydataset)

Imports System.Data.OracleClient //I compiled the project to .net 3.5. there is a warning for system.threading.tasks but not for system.data.oracleclient

Public Class Form1
Dim cString As String = "Data Source=usr/pw@host:1521/orcl"
Dim myCon As OracleConnection = New OracleConnection(cString)
Dim myAdapter As OracleDataAdapter = New OracleDataAdapter("select * from courses", cString)
Dim myDataSet As DataSet = New DataSet
myAdapter.fill(myDataset) //Declaration expected
//this strange behavior might be a clue ... Dim m as OracleDataReader = new OracleDataReader yields overload resolution failed because no new is accessible
4

2 回答 2

1

您需要放入.Fill一个函数或子程序。除非用于初始化成员,否则您不能在表单定义中使用代码。我怀疑你想要类似的东西:

Public Class Form1
Dim cString As String = "Data Source=usr/pw@host:1521/orcl"
Dim myCon As OracleConnection = New OracleConnection(cString)
Dim myAdapter As OracleDataAdapter = New OracleDataAdapter("select * from courses", cString)
Dim myDataSet As DataSet = New DataSet

Private Sub FillData()
    myAdapter.fill(myDataset) 
End Sub

然后FillData在合适的地方打电话。

于 2013-05-01T13:28:42.500 回答
0

没有fill()(小写f)。但是,有Fill()(大写F)。

于 2013-05-01T13:20:06.780 回答