无法从oracle服务器获取数据到System.Data.DataTable

时间:2013-04-18 10:26:53

标签: vb.net oracle

我正在调用以下查询从我的vb.net应用程序到oracle服务器,同样的查询在我的oracle sql开发人员上执行并正确地给出了结果。但是当从vb.net代码调用相同的查询时,结果在数据表中出现零行而没有任何异常。

提前致谢。

的Oracle

with sdk as (select roll_no from student where roll_no='1001';)
select * from sdk;

VB

Dim MyconnectionString As String = "provider=MSDAORA.1;data source=student;user id=ss;password=1234;
Dim myOleDbConnection As New OleDbConnection(MyconnectionString)

Dim loDataTable As New DataTable
Dim loCommand As New OleDbCommand
Dim loDataAdapter As New OleDbDataAdapter

loCommand.CommandText = "with sdk as (select roll_no from student where roll_no='1001')select * from sdk;"                
loCommand.CommandType = CommandType.Text
loCommand.Connection = myOleDbConnection
loCommand.CommandTimeout = 0
loDataAdapter.SelectCommand = loCommand
loDataAdapter.Fill(loDataTable)

1 个答案:

答案 0 :(得分:0)

您有两个不同的查询:

with sdk as (select roll_no from student where roll_no='1001';)

VS

with sdk as (select roll_no from student where roll_no='1005')

所以我猜你有roll_no = 1001的数据,但没有roll_no = 1005的数据