473,385 Members | 1,449 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,385 software developers and data experts.

Prefetch

Hi,
I'm receveing an IDataReader object that I bind to a combo list.

I'd like to be able to customize that object before binding it to combo,
but I don't know how to do it...

Ideal would be something aka:

foreach('MyField' in IDataReader.Rows){

If ('MyField'== "Male")
IDataReader.Row.Remove('MyField');
};

TIA
Nov 16 '05 #1
6 3520

"Peter Osawa" <po****@sun.es> wrote in message
news:Oh*************@TK2MSFTNGP10.phx.gbl...
Hi,
I'm receveing an IDataReader object that I bind to a combo list.

I'd like to be able to customize that object before binding it to combo,
but I don't know how to do it...

Ideal would be something aka:

foreach('MyField' in IDataReader.Rows){

If ('MyField'== "Male")
IDataReader.Row.Remove('MyField');
};


Use a DataTable instead of a DataReader. Then you can do whatever you want
to it.

David
Nov 16 '05 #2
The problem es that I receive the IDataReader and I'm not allowed to
change that...

David Browne wrote:
"Peter Osawa" <po****@sun.es> wrote in message
news:Oh*************@TK2MSFTNGP10.phx.gbl...
Hi,
I'm receveing an IDataReader object that I bind to a combo list.

I'd like to be able to customize that object before binding it to combo,
but I don't know how to do it...

Ideal would be something aka:

foreach('MyField' in IDataReader.Rows){

If ('MyField'== "Male")
IDataReader.Row.Remove('MyField');
};

Use a DataTable instead of a DataReader. Then you can do whatever you want
to it.

David

Nov 16 '05 #3

"Peter Osawa" <po****@sun.es> wrote in message
news:eJ*************@TK2MSFTNGP11.phx.gbl...
The problem es that I receive the IDataReader and I'm not allowed to
change that...

David Browne wrote:
"Peter Osawa" <po****@sun.es> wrote in message
news:Oh*************@TK2MSFTNGP10.phx.gbl...
Hi,
I'm receveing an IDataReader object that I bind to a combo list.

I'd like to be able to customize that object before binding it to combo,
but I don't know how to do it...

Ideal would be something aka:

foreach('MyField' in IDataReader.Rows){

If ('MyField'== "Male")
IDataReader.Row.Remove('MyField');
};

Use a DataTable instead of a DataReader. Then you can do whatever you want
to it.

David


The following will convert the Reader to a DataTable. I don't know how to do
this using any methods on any of the Sql objects, because I haven't spent much
time with the Reader specifically. So I wrote this quickly to help you in your
situation.

Hope it helps!

Mythran
' --------------------------------------------------------------------------
' Description:
' Sample MAIN() console application.
'
Sub Main()
Dim conn As SqlConnection
Dim read As SqlDataReader
Dim adap As SqlDataAdapter
Dim dt As DataTable
Dim cmd As SqlCommand

conn = New
SqlConnection("Server=MyServer;Database=MyDatabase ;Trusted_Connection=True")
conn.Open()

cmd = New SqlCommand("SELECT * FROM tblDepartment", conn)
read = cmd.ExecuteReader()

' Convert the reader to a data table.
dt = ConvertReaderToDataTable(read)

' Close the reader and the database connection.
read.Close()
conn.Close()

' Write the first row of the data table.
For Each col As DataColumn In dt.Columns
Console.WriteLine("Name: " & col.ColumnName & _
" - Value: " & dt.Rows(0)(col).ToString())
Next
End Sub

' --------------------------------------------------------------------------
' Description:
' Convert the reader to a data table.
'
Public Function ConvertReaderToDataTable(ByVal Reader As SqlDataReader) As
DataTable
Dim dt As DataTable
Dim dr As DataRow

' Create the data table.
dt = New DataTable()

' Add the columns from the reader to the schema of the data table.
For i As Integer = 0 To Reader.FieldCount - 1
dt.Columns.Add(Reader.GetName(i), Reader.GetFieldType(i))
Next

' Add each row in the reader to the data table.
While Reader.Read()
' Create the new row.
dr = dt.NewRow()

For i As Integer = 0 To Reader.FieldCount - 1
dr(i) = Reader(i)
Next

' Add the row to the table.
dt.Rows.Add(dr)
End While

' Return the DataTable object.
Return dt
End Function

Nov 16 '05 #4
Sorry about my previous post in VB.Net, it's not hard to convert to C#, but
still, sorry ... didn't notice this was the C# group until after I posted
heh...let me know if you have problems converting to C#...if you do I'll go ahead
and convert it to the equivalent.

....

Mythran

"Peter Osawa" <po****@sun.es> wrote in message
news:eJ*************@TK2MSFTNGP11.phx.gbl...
The problem es that I receive the IDataReader and I'm not allowed to
change that...

David Browne wrote:
"Peter Osawa" <po****@sun.es> wrote in message
news:Oh*************@TK2MSFTNGP10.phx.gbl...
Hi,
I'm receveing an IDataReader object that I bind to a combo list.

I'd like to be able to customize that object before binding it to combo,
but I don't know how to do it...

Ideal would be something aka:

foreach('MyField' in IDataReader.Rows){

If ('MyField'== "Male")
IDataReader.Row.Remove('MyField');
};

Use a DataTable instead of a DataReader. Then you can do whatever you want
to it.

David

Nov 16 '05 #5

"Peter Osawa" <po****@sun.es> wrote in message
news:eJ*************@TK2MSFTNGP11.phx.gbl...
The problem es that I receive the IDataReader and I'm not allowed to
change that...


Well, that's bad design.

But you can create the DataTable yourself and read through the DataReader
and add rows to the DataTable. You're replicating code that already exists
in the DataAdapter.

David
Nov 16 '05 #6
I'll try it

Thank you

Mythran wrote:
Sorry about my previous post in VB.Net, it's not hard to convert to C#, but
still, sorry ... didn't notice this was the C# group until after I posted
heh...let me know if you have problems converting to C#...if you do I'll go ahead
and convert it to the equivalent.

...

Mythran

"Peter Osawa" <po****@sun.es> wrote in message
news:eJ*************@TK2MSFTNGP11.phx.gbl...
The problem es that I receive the IDataReader and I'm not allowed to
change that...

David Browne wrote:

"Peter Osawa" <po****@sun.es> wrote in message
news:Oh*************@TK2MSFTNGP10.phx.gbl...
Hi,
I'm receveing an IDataReader object that I bind to a combo list.

I'd like to be able to customize that object before binding it to combo,
but I don't know how to do it...

Ideal would be something aka:

foreach('MyField' in IDataReader.Rows){

If ('MyField'== "Male")
IDataReader.Row.Remove('MyField');
};
Use a DataTable instead of a DataReader. Then you can do whatever you want
to it.

David


Nov 16 '05 #7

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

Similar topics

1
by: Li Kao | last post by:
After incrementally increasing SORTHEAP (and the commensurate increase in SHEAPTHRES) and *slightly* reducing the bufferpool size, I find that my query is no longer taking advantage of async IO for...
4
by: Erik Hendrix | last post by:
Hi, I have a quick question, when one sets the prefetch size = extent size, then when doing a backup we will have 1 agent (db2bm) doing the reads. If we have prefetch size a multiple of extent...
1
by: Erik Hendrix | last post by:
Hi, I have a question here regarding setting the prefetch size. So far we took the rule that for OLTP, prefetchsize = extent size and for DSS prefetchsize = extent size * number. However,...
2
by: Jean-Marc Blaise | last post by:
Dear all, If you do a SELECT * FROM TAB WHERE DATE=?, the explain plan might pick up a TBSCAN and you'll see in db2exfmt PREFETCH=SEQUENTIAL. Now, TAB is a MDC, and DATE is a dimension. The...
6
by: Ioannis Theoharis | last post by:
Hi, i have 3 tables calling father, child1, child2: create table father(att0 int4); create table child1() inherits(father); create table child2() inherits(father); i want to get all the...
3
by: rdudejr | last post by:
Hi all, Ive got a database approx 350 GB in which Im getting very high Time waited for prefetch. This is directly out of the snapshot for the db (these are for the entire database I assume as I...
1
by: msasha | last post by:
Hi all. I'm trying to parse some HTML received from an untrusted remote source. What I've been trying so far is something along the lines of: var htmlString = "<script...
0
by: dunleav1 | last post by:
Does it make sense to set prefetch automatic on a temp tablespace?
1
by: =?Utf-8?B?Sm9ubnk=?= | last post by:
Hi. I an pulling my hair out with this one and hope somebody can help me.I started getting a message on startuo saying windows/prefetch/explorer.exe -082F38A9.pf is corrupt.Since then every time...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.