Accessing Custom ADO Datasets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a representation of a relational structure using the XML schema
template. I've populated the structure using a series of 'flat' text files
(I'm doing this in anticipcation of also accessing an Oracle structure at a
later date). I've defined 'keys' on the relational structure. How do I access
data rows based on key values - for example I might have a key defined as
'first name', 'surname' - the only way I seem to be able to access the data
is to set up a FOR loop and compare the 2 data columns. Is there a way to set
up a 'query' which returns the row in a single statement?

thanks
 
Dim strSelect As String = "Col1 = '" & strvar1 & "' and Col2 = " &
intvar2
Dim dtRow() as DataRow = myDataSet.Tables(0).Select(strSelect)

you could use.. dtRow array and store it in DataSet, and manuiplate.. or
get the refrence row from dtRow array and directly update your primary
datasource...
 
Rob,

Beside the method VJ mentioned can you use to get a reference to that row

dataview.rowfilter = and than by instance use the same filter as VJ shows
you
datarowcollection.find which returns the datarow accoording to the primary
keys
dataview.find wich returns the postition in the dataview accoording to keys.

I hope this helps,

Cor
 
Thanks VJ, Cor. I will try these methods out. The performance of the 'query'
will be interesting - at the moment I am using hashtables within hashtables
to simulate 1-to-Many relationships but this all starts to get hard when
going beyond this level of relationship or when you move into having complex
compound keys. Do you know if the definition of 'keys' on datatables actually
aid performance or are they there to maintain relational contraints?
 
Keys most definitely improve performance.

Thanks VJ, Cor. I will try these methods out. The performance of the 'query'
will be interesting - at the moment I am using hashtables within hashtables
to simulate 1-to-Many relationships but this all starts to get hard when
going beyond this level of relationship or when you move into having complex
compound keys. Do you know if the definition of 'keys' on datatables actually
aid performance or are they there to maintain relational contraints?
 
Rob,

Now I see the message from Jay, I see that I got your message completly
wrong in my mind, therefore a correction. (Although probably that previous
is as well useful for what you are doing).

Keys make it you possible to select easy one DataRow from a DataTable. I am
not sure if there is real a performance benefit. That will depends as well
how you create them and how you use them. (When you create them one time
and use those 1000 times, it will be obvious that it is faster, in the
oposite way I am not sure).

I have seen that sometimes the datatable.select is much faster than the
dataview.rowfilter. However when the dataview is sorted and the rowfilter is
about that key, than the rowfilter is again faster.

Therefore I cannot give a real answer what is always faster.

Cor
 

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

Back
Top