473,406 Members | 2,451 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,406 software developers and data experts.

Filling a datagrid from Oracle

I have a datagrid that has to be filled in a WinForms application. The
data comes from an Oracle database.

The normal procedure would be filling a dataset, but I have the problem
that there are over 100.000 records in the tables, so this has very low
performance when executing.

I then tried using an OracleDataReader, but for some reason, I cannot
bind my reader to the datagrid, I get the following error:
"Complex DataBinding accepts as a data source either an IList or an
IListSource"

I use the following code for this reader:
Public Shared Function ReadAllExistingReader() As
OracleClient.OracleDataReader
Dim sqlCommand As String = "SELECT * FROM THTEST"

' DataSet that will hold the returned results

Dim pReader As OracleClient.OracleDataReader
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim pOraConnection As OracleClient.OracleConnection
pOraConnection = CType(db.GetConnection(),
OracleClient.OracleConnection)
Dim comm As OracleClient.OracleCommand = New
OracleClient.OracleCommand(sqlCommand, pOraConnection)

Try
pOraConnection.Open()
pReader =
comm.ExecuteReader(CommandBehavior.CloseConnection )

Catch ex As Exception

Throw New Exception(ex.Message)
Finally

End Try

Return pReader
End Function

And this is bound this way:
Dim reader As System.Data.OracleClient.OracleDataReader =
DAL.THTest.ReadAllExistingReader

..........
With Me.grdTHTest
.RowHeadersVisible = False
.DataSource = reader
.CaptionText = "TH Test"
.ReadOnly = True
End With

Anyone has a solution?

Jan 18 '06 #1
4 10554
You don't want to use a data reader. Rather, you want to take your
command that performs the select and set it as the SelectCommand on the
OracleDataAdapter class. Then, you can call the Fill method, passing a
DataSet which is filled with the result set.

You can then bind that result set to your data grid.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"gillcleeren@google mail DOT com" <gi*********@gmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
I have a datagrid that has to be filled in a WinForms application. The
data comes from an Oracle database.

The normal procedure would be filling a dataset, but I have the problem
that there are over 100.000 records in the tables, so this has very low
performance when executing.

I then tried using an OracleDataReader, but for some reason, I cannot
bind my reader to the datagrid, I get the following error:
"Complex DataBinding accepts as a data source either an IList or an
IListSource"

I use the following code for this reader:
Public Shared Function ReadAllExistingReader() As
OracleClient.OracleDataReader
Dim sqlCommand As String = "SELECT * FROM THTEST"

' DataSet that will hold the returned results

Dim pReader As OracleClient.OracleDataReader
Dim db As Database = DatabaseFactory.CreateDatabase()
Dim pOraConnection As OracleClient.OracleConnection
pOraConnection = CType(db.GetConnection(),
OracleClient.OracleConnection)
Dim comm As OracleClient.OracleCommand = New
OracleClient.OracleCommand(sqlCommand, pOraConnection)

Try
pOraConnection.Open()
pReader =
comm.ExecuteReader(CommandBehavior.CloseConnection )

Catch ex As Exception

Throw New Exception(ex.Message)
Finally

End Try

Return pReader
End Function

And this is bound this way:
Dim reader As System.Data.OracleClient.OracleDataReader =
DAL.THTest.ReadAllExistingReader

.........
With Me.grdTHTest
.RowHeadersVisible = False
.DataSource = reader
.CaptionText = "TH Test"
.ReadOnly = True
End With

Anyone has a solution?

Jan 18 '06 #2
Hi,

"gillcleeren@google mail DOT com" <gi*********@gmail.com> wrote in message
news:11********************@o13g2000cwo.googlegrou ps.com...
I have a datagrid that has to be filled in a WinForms application. The
data comes from an Oracle database.

The normal procedure would be filling a dataset, but I have the problem
that there are over 100.000 records in the tables, so this has very low
performance when executing.


You need to retrieve only those records that you are going to use, depending
of how your records are organized you can create a SP that returns N records
with IDs less than/greater than a particular ID that represent the top
record.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 18 '06 #3
Do you mean some kind of grid paging like in ASP.net?

Do you have an example on how this works in winforms?

Thanks

gill

Jan 18 '06 #4
Hi,

"gillcleeren@google mail DOT com" <gi*********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Do you mean some kind of grid paging like in ASP.net?

Do you have an example on how this works in winforms?

Thanks


Well, I did it in ASP.NET but the idea is the same, you have your grid, two
buttons "next" "previous" and depending of which you click you go one page
down/one page up
yuo just bind the grid in each situation

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jim Ptak via .NET 247 | last post by:
I am desperate for help. I am at a loss. I have a dataset with 4columns in it. The first column is an actual column from adatabase table. The last three columns are hard codded values of0. I am using...
1
by: Krzysztof Karnicki | last post by:
I have such a problem… I have create my custom DataGridColumn inheriting from System.Windows.Forms.DataGridColumnStyle on using it on DataGrid, to show rows painted by me self. Because dates ...
2
by: tshad | last post by:
I have a datagrid that has objects that are not visible and I need to use them in my Sql Statement. The problem is they are not there when set as "visible=false", but they are if set to true. ...
1
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). ...
2
by: Parveen | last post by:
When I fill the same dataset table with new information from the database, instead of writing over any previous data, the fill method appends to existing records in this dataset table. Is there a...
1
by: reidarT | last post by:
I want to fill a datagrid with different dataadapters. The problem is to refresh the datagrid. How do I populate the datagrid with different dataadapters? I use buttons to do this button1...
0
by: Tony A. | last post by:
I'm using VB 2005 with MS Access for as the database. I have a table (tblItem) that has two columns, ItemNum (key field) and ItemDescription. I also have a second table (tblOrdersDetail), this...
1
by: WayneM | last post by:
I have compact framework app that I was trying to test out on a windows form, but I cannot get past the very first step of simply filling a DataGrid from a DataSet. My code is Dim sqlStmt As...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.