473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

getting oracle table results into array using odp.net

58
Hey all,
So hopefully this is a quick fix but for the life of me I can't figure out how to get my results from a OracleDataReader record set.
Just trying to get all the users for a specific TNS into an array. I was able to do this easily before with ADODB, but thought I would try using ODP.net.

Here is what I have so far and it definitely gets all the USERs for a given TNS. its when I get to the READ() part where the syntax is ???

'TNSname, User and password are all variables declared before this

/CODE

Dim oradb As String = "Data Source=" & TNSname & ";User Id=" & User & ";Password=" & password & ";" ' Visual Basic
Dim Inconn As New OracleConnection(oradb) ' Visual Basic
Inconn.ConnectionString = oradb
Inconn.Open()

Dim sql As String = "SELECT USERNAME FROM dba_users where default_tablespace != 'SYSAUX' and default_tablespace != 'SYSTEM' and default_tablespace != 'TOOLS' and default_tablespace != 'USERS' ORDER BY USERNAME" ' Visual Basic

Dim cmd As New OracleCommand(sql, Inconn)
cmd.CommandType = CommandType.Text

Dim inRS As OracleDataReader = cmd.ExecuteReader()

Dim arrTemp() As String = {}
Dim i As Integer = 0

While inRS.Read()

arrTemp(i) = inRS.GetString(0).ToString
i = i + 1

End While

inRS.Close()
Inconn.Close()

/CODE

Its strange as I can easily populate a text or combo box during the read by just saying

While inRS.Read()
cbo_test.items.add(inRS.Item("USERNAME"))
End While

I would appreciate anyones thoughts and or direction here as I would rather not go back to ADOBD...
Thanks ahead of time!
Cheers,
Eric
Oct 5 '09 #1
1 2583
erbrose
58
well its long winded and slightly backwards but it works....

/CODE

Dim arrTemp As String


Dim inRS As OracleDataReader = cmd.ExecuteReader()

While inRS.Read()
'arrTemp.ToString = inRS("USERNAME")

arrTemp = arrTemp & "," & inRS.Item("USERNAME")

End While

Dim arrTemp2() As String = {}
arrTemp2 = Split(arrTemp, ",")

Dim arrTemp3() As String = {}
ReDim arrTemp3(UBound(arrTemp2) - 1)

Dim j As Integer = 0

For i As Integer = 1 To UBound(arrTemp2) - 1
arrTemp3(j) = arrTemp2(i)
j = j + 1
Next

getArrayOfTables = arrTemp3

inRS.Close()
Inconn.Close()

/CODE
Oct 6 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Philip D Heady | last post by:
Ok I'm a newbie to using Oracle9i w/ PHP, been a MySQL guy... What is the proper sql statement to use insert tables, etc. as below.? I don't know much about how OciParse works. I can connect...
9
by: Philip D Heady | last post by:
Ok, as some of you may know I'm an Oracle newbie w/ PHP. I'd rather use MySQL but at the office here we use Oracle and boy do I have alot to learn. I'm starting to hate it after using MySQL!! ...
4
by: susmita_ganguly | last post by:
Hi I am trying to upgrade from oracle 8i to oracle 9i on the same server ..I don't know much abt migration . Can anyone help me out. Thanks. Susmita
0
by: sarith sutha | last post by:
Hi Guys Need a help i am facing a sporadic issue when executing the query using nested table of numbers Here are the things which i did 1. I created a type as CREATE TYPE NUMBERTABLE AS...
1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
8
by: Alfonso Esteban Gonzalez Sencion | last post by:
I am trying to use Access as a front end for extracting information from an Oracle database. I started using linked tables but I am getting a very curious behaviour. When I consult the linked...
11
by: Chris Fink | last post by:
I have setup an Oracle table which contains a blob field. How do I insert data into this field using C# and ADO.net?
0
by: RLN | last post by:
I have a Microsoft Access2002 database that needs to connect to an Oracle Database. I need to map 2 tables from the Oracle DB to retrieve the proper data. I read somewhere (quite a while back)...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.