Binding a DataAdapter to a DataGrid

J

javabunch

Hello,
I am new to .Net and ADO.NET. I used Visual Studo .Net to create a
Oracle DataAdapter. Now I want to bind to a DataGrid to display the
result of the SQL Statment. I tried the following source code but it
does not work :-(

Here the code:

DataTable myTable = new DataTable();
DataSet myDataset = new DataSet();
oracleDataAdapter1.Fill(myTable);
myDataset.Tables.Add(myTable);
dataGrid1.DataSource = ;
dataGrid1.Visible = true;

Could someone tell me what I am doing wrong? I am happy for any help
:)

Greetings

Javabunch
 
C

Cor Ligthert

JavaBunch

We love those simple ones
DataTable myTable = new DataTable();
oracleDataAdapter1.Fill(myTable);
assuming you have made the connection and the selectstring in the
construction of the dataadapter or any other way.
dataGrid1.DataSource = myTable;

The most simple one, you can change DataTable for Dataset and than as
datasource in this case
myDataset.Tables[0];

I hope this helps?

Cor
 
J

javabunch

Hello,
Thanks for help. Now I am not getting a error message but it does not
display the result of the sql statment that it should. I use the
following code. Do I have to connect the DataAdapter in another way?
I use the update methode in the moment.

Sourcecode:
DataTable myTable = new DataTable();
oracleDataAdapter1.Update(myDataset);
dataGrid1.DataSource = myDataset;
dataGrid1.Visible = true;

I tried to used the oracleDataAdapter.Fill Methode but I got the same
error message :-( So I used update() instead of fill()

By the way I am german so please excuse my english.

Thanks for your help

Greetings

Javabunch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top