none
Using an IDataReader remotely RRS feed

  • Question

  •  

    Hi,

     

    We have created a custom ADO.NET DataProvider to communicate with our proprietary DB on .NET2.  This all works fine except for one problem...

     

    We need to provide an IDataReader to the client (sometimes over a .NET remoting boundary) . Unfortunately one of the calls in the IDataReader does not get marhalled correctly.  This is - int GetValues( object[] values );

     

    GetValues populates the passed values array with the row data for the current row and returns the number of columns populated.  This all works fine and if I set up a test app without remoting I get the row data perfectly,  however object[] arrays are not marshalled back from the server to the client when called remotely. 

     

    I created a test app to be sure of this and sure-enough if I pass an array containing a single string to the server it receives the array and can change it to contain new values before returning, however the client does not see the changed list on return, but still has the array in its original form.

     

    So, I cant change my code - because GetValues is part of IDataReader and I cant see any way of fooling this into marshalling the array in both directions without changing the method sig and so failing the interface. I find it hard to believe that IDataReader wouldnt work remotely, so I feel I must be missing something.

     

    If anybody has any ideas, or suggestions I'd be hugely grateful.

     

    Cheers

    John

    Wednesday, October 31, 2007 12:16 PM

All replies

  • The DataReader is not ment to be used over .NET Remoting and doings so will have a hugh performance impact since all calls get marshaled over the network. When version .NET 1 was released we made a performance comparision with DataReader and DataSet and the DataReader was 30 times slower when used over the network even though we only read one column. If we had read more than one column this would be even worse. The DataSet or a custom serializable class would be a better option.

     

    To be able to get the values back from the above call the parameter would have to be sent by reference, and as you say yourself that would break the contract.

    Thursday, November 1, 2007 8:13 PM
  • Hi,

     

    Thanks for replying - I was beginning to think this would drift down the list unanswered!

     

    I appreciate that using an IDataReader would have network implications - although it does make only one call per row (calls GetValues rather than GetValue per column).

     

    But the trouble with DataSets is they are sent across as a single Blob - the entire rowset is retrieved and sent to the client in one package.  Our clients use of data is read-only within a grid control so we really want to just retrieve a window of records around the users current viewed start record.

     

    If DataSets were capable of paging data across the boundary they would be ideal as we really only want the client to see a say 100 block window of records from the server at any one time which a RecordSet reader allows us to do. I couldnt see any capability in the DataSet to do that. If I'm missing something here that would be great - this is my first heavy usage of ADO.NET so its entirely possible!

     

    Cheers again for replying

    John

    Friday, November 2, 2007 9:21 AM
  • High performance of remoting ADO.NET objects, DataSet, DataTable and IDataReader

    http://www.udaparts.com/groups/viewtopic.php?t=534
    Friday, November 2, 2007 9:39 PM
  • It is ont that hard to create paged DataSet where you only Fill 100 rows each time. When you get next 100 rows you could easily use Merge of the DataSet to get one DataSet with 200 rows and so on.

     

    There is an overload of DataAdapter.Fill where you can send startRecord and maxRecords as parameters. This will get you the number of rows indicated in maxRecords. In the next fill you use set the startRecord parameter to a value equal to maxRecords + 1.

     

    Saturday, November 3, 2007 8:25 PM
  • Thanks for the replies.

     

    On the udparts reply - it looks good but unfortunately I cant use this as we use a single bi-directional port for all our remoting (GenuineChannels) and this goes straight to winsock and gets its own ports - but thanks.

     

    I'll have a look at the DataAdapter.Fill and writing some paging code.  I'm really suprised how little support ADO.NET has for large databases and remoting - I really though it would have implemented some kind of paging and network awareness of its own -- oh well time to reinvent that wheel again!

     

    Thanks

    John

     

    Monday, November 5, 2007 9:58 AM