How do i fill datagrid w/ oracle ?

G

Guest

hi,

i have created a connection and using the oracle connection + oracle data adapters,
but when i try to change the select statement and re-fill the datagrid; i get nothing. however, when i fill the data adapter from the data adapter interface/wizard; the datagrid is filled when i run it. what am i missing ? code is below:

Dim conn As New OracleClient.OracleConnection
' TODO: Modify the connection string and include any
' additional required properties for your database.
conn.ConnectionString = OracleConnection1.ConnectionString '"Data Source=<oracle data source name>;Integrated Security=yes"
Try
Dim mycommand As System.Data.OracleClient.OracleCommand
Dim myadapter As New System.Data.OracleClient.OracleDataAdapter

mycommand = New System.Data.OracleClient.OracleCommand
mycommand.Connection = conn
mycommand.CommandText = "select * from master_well_header where iuwi = '60804402080000'"

myadapter = New System.Data.OracleClient.OracleDataAdapter
myadapter.SelectCommand = mycommand

conn.Open()
myadapter.Fill(DataSet11)
DataGrid1.SetDataBinding(DataSet11, "")

Catch ex As Exception
MessageBox.Show("Failed to connect to data source", ex.Message)
Finally
conn.Close()
End Try
 
M

Miha Markic [MVP C#]

Hi Lee,

You don't need dataset.
Create a DataTable and fill it directly, something like this:
DataTable table = new DataTable();
myadapter.Fill(table);
or if you have strong typed dataset (I guess you have one):
myadapter.Fill(DataSet11.MyTable);

and bind grid to it:
DataGrid1.DataSource = table;
or
DataGrid1.DataSource = DataSet11.MyTable;

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Lee Holsenbeck said:
hi,

i have created a connection and using the oracle connection + oracle data adapters,
but when i try to change the select statement and re-fill the datagrid; i
get nothing. however, when i fill the data adapter from the data adapter
interface/wizard; the datagrid is filled when i run it. what am i missing ?
code is below:
 
R

rbutch

personally - i would create a stored procedure on the oracle db itself. note * you have to use a ref cursor.
i was amazed how much faster the select statments ran when processed from the Oracle side.
there's just a lot more code to write, but the performance is worth it.
thanks
rik

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 

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