How to fill DataGridView from nested table oracle

Posted by arkadiusz85 on Stack Overflow See other posts from Stack Overflow or by arkadiusz85
Published on 2010-05-04T12:04:28Z Indexed on 2010/05/04 12:08 UTC
Read the original article Hit count: 439

Filed under:
|
|

I want to create my type:

CREATE TYPE t_read AS OBJECT (
id_worker NUMBER(20),
how_much NUMBER(5,2),
adddate_r DATE,
date_from DATE,
date_to DATE
);

I create a table of my type:

CREATE TYPE t_tab_read AS TABLE OF t_read;

Next step is create a table with my type:

    enter code hereCREATE TABLE Reading (
id_watermeter NUMBER(20) constraint Watermeter_fk1 references Watermeters(id_watermeter), 
read t_tab_read
)
NESTED TABLE read STORE AS store_read ;

Microsoft Visual Studio can not display this type in DataGridView. I use Oracle.Command:

C#
using Oracle.DataAccess;
using Oracle.DataAccess.Client;

private void button1_Click(object sender, EventArgs e)
{
try
{
//my working class to connect to database
ConnectionClass.BeginConnection();
OracleDataAdapter tmp = new OracleDataAdapter();
tmp = ConnectionClass.ReadCommand(ReadClass.test());
DataSet dataset4 = new DataSet();
tmp.Fill(dataset4, "Read1");
dataGridView4.DataSource = dataset4.Tables["Read1"];

}
catch (Exception o)
{
MessageBox.Show(o.Message);
}
public class ReadClass
{ 
public static OracleCommand test()
{
string sql = "select c.id_watermeter, a. from reading c , table (c.read) a where id_watermeter=1";
ConnectionClass.Command1= new OracleCommand(sql, ConnectionClass.Connection);
ConnectionClass.Command1.CommandType = CommandType.Text;
return ConnectionClass.Command1;
}
}

I tray:

string sql = "select r.id_watermeter, o.id_worker, o.how_much, o.adddate_r, o.date_from, o.date_to from reading r, table (r.read) o where r.id_watermeter=1"
string sql = "select a.from reading c , Table (c.read) a where id_watermeter=1"
string sql = "select a.id_worker, a.how_much, a.adddate_r, a.date_from, a.date_to from reading c , table (c.read) a where id_watermeter=1"
string sql = "select c.id_watermeter, a. from reading c , table (c.read) a where id_watermeter=1"

Error : Unsuported Oracle data type USERDEFINED encountered Sombady can help me how to fill DataGridView using data from nested table. I am using Oracle 10g XE

© Stack Overflow or respective owner

Related posts about datagridview

Related posts about nested