This source code shows how to get all database tables and their columns from an Oracle database using Oracle .NET Data Provider available in the .NET Framework class library.
To run this sample, you need to add your connection string to the following line:
OracleConnection connection = new OracleConnection("Connection String");
Here is the complete source code:
using System;
using System.Data.OracleClient;
using System.Windows.Forms;
using System.Data;
Public Class Query : System.Windows.Forms.Form
{
System.Windows.Forms.ListBox lstColumns;
System.Windows.Forms.ListBox lstTables;
Public Query()
{
BindTables();
}
//Fill tables and columns into the listboxes
Private void BindTables()
{
lstTables.Items.Clear();
//Execute the query.
try{
OracleConnection connection = new OracleConnection("Connection String");
OracleDataAdapter adap = new OracleDataAdapter ("select * from tabs", connection);
DataTable dt = new DataTable();
adap.Fill(dt);
//Display the table name from each row in the schema
foreach (DataRow row In dt.Rows)
lstTables.Items.Add(row("Table_Name"));
}
catch(Exception ex)
{
MessageBox.Show("Error" + ex.Message, "Error");
}
}
//Table listBox select event to change columns in the colum listbox accordingly
Mo ItaniPosted Jan 5, 2024, 4:53 PM
Is there a way to do the same using GetSchema()?
asdullah khan ghalibPosted Oct 15, 2010, 5:59 AM
thanks this will help me alot
hema maliniPosted Oct 17, 2006, 8:36 AM
Hi, I am having oracle 9i installed in the server. From the client machine I want to get all the database names(service names) which are available in the server through vb.net. Also in SQLDMO , we have a method to get all available servers in the network as LISTAVAILABLESERVERS(). Like that, is there any method in oracle? Kindly help me. Regards, Hema.
kannan seditedPosted Feb 24, 2006, 3:08 AMEdited Jan 8, 2007, 11:48 AM
hai, i used your coding for to oracle in asp.net (C#) But it mentioning the error as UNABLE TO LOAD OCI.DLL please reply us to [email protected] [email protected]
Mahesh ChandPosted Nov 8, 2005, 4:16 PM
Someone was looking for it on forums. Cheers!