473,573 Members | 3,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 OracleDataReade r, 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 ReadAllExisting Reader() As
OracleClient.Or acleDataReader
Dim sqlCommand As String = "SELECT * FROM THTEST"

' DataSet that will hold the returned results

Dim pReader As OracleClient.Or acleDataReader
Dim db As Database = DatabaseFactory .CreateDatabase ()
Dim pOraConnection As OracleClient.Or acleConnection
pOraConnection = CType(db.GetCon nection(),
OracleClient.Or acleConnection)
Dim comm As OracleClient.Or acleCommand = New
OracleClient.Or acleCommand(sql Command, pOraConnection)

Try
pOraConnection. Open()
pReader =
comm.ExecuteRea der(CommandBeha vior.CloseConne ction)

Catch ex As Exception

Throw New Exception(ex.Me ssage)
Finally

End Try

Return pReader
End Function

And this is bound this way:
Dim reader As System.Data.Ora cleClient.Oracl eDataReader =
DAL.THTest.Read AllExistingRead er

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

Anyone has a solution?

Jan 18 '06 #1
4 10570
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
OracleDataAdapt er 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.co m

"gillcleeren@go ogle mail DOT com" <gi*********@gm ail.com> wrote in message
news:11******** ************@o1 3g2000cwo.googl egroups.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 OracleDataReade r, 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 ReadAllExisting Reader() As
OracleClient.Or acleDataReader
Dim sqlCommand As String = "SELECT * FROM THTEST"

' DataSet that will hold the returned results

Dim pReader As OracleClient.Or acleDataReader
Dim db As Database = DatabaseFactory .CreateDatabase ()
Dim pOraConnection As OracleClient.Or acleConnection
pOraConnection = CType(db.GetCon nection(),
OracleClient.Or acleConnection)
Dim comm As OracleClient.Or acleCommand = New
OracleClient.Or acleCommand(sql Command, pOraConnection)

Try
pOraConnection. Open()
pReader =
comm.ExecuteRea der(CommandBeha vior.CloseConne ction)

Catch ex As Exception

Throw New Exception(ex.Me ssage)
Finally

End Try

Return pReader
End Function

And this is bound this way:
Dim reader As System.Data.Ora cleClient.Oracl eDataReader =
DAL.THTest.Read AllExistingRead er

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

Anyone has a solution?

Jan 18 '06 #2
Hi,

"gillcleeren@go ogle mail DOT com" <gi*********@gm ail.com> wrote in message
news:11******** ************@o1 3g2000cwo.googl egroups.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@go ogle mail DOT com" <gi*********@gm ail.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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
6390
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 this dataset to populate a datagrid. The datagridhas a datagridtablestyle that has all four columns with the lastthree being DataGridBoolColumn's....
1
2198
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 taken from database are very large, and filling DataSet bounded to this DataGrid takes some time, a decided to put fill logic into new thread. And so...
2
1299
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. For example: I have: *****************************************************************************************
1
2113
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). Both ASCXs have DataGrids on them. The first user control's DataGrid is populated from our database on page load. The DataGrid also has a Select...
2
2263
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 way by which I can overwrite existing data in the dataset instead of appending to it? Thanks, Parveen
1
1321
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 Private Sub cmdAnsatt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAnsatt.Click OleDbDAAnsatt.Fill(DsAnsatt)...
0
1110
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 table has two columns ItemNum and ItemDescription Using a Datagrid View that is bound to the tblOrdersDetail table. When a users enters a number...
1
1587
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 String = "Select VendorName, StartWeek from InventorySchedule Where FinishDate is Null and StartWeek<'" & Now & "'" Dim cmdDB As New...
8
3058
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 reflect the values they anticipate committing to see hypothetical totals of columns from a set of records. These records are displaying properly...
0
7660
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7977
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8163
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7729
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6346
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5252
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2163
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
984
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.