?
Solved

NEWBIE: What C# object is closest to Java ResultSet?

Posted on 2006-04-26
12
Medium Priority
?
782 Views
Last Modified: 2012-05-05
Dear Experts,

I'm converting an app from Java to C# (at which I'm a newbie).  I'm just getting exposed to the ADO.NET "disconnected" data model.  In Java, I had been relying exclusively on "ResultSets", which are "connected".  Apparently, I'll need to learn something different in ADO.NET.  

My particular app was modeled on (ported from, actually) a main-frame batch program.  When it's "back-end processing" runs, it's guaranteed to be the only app running against the entire db at that time.  

Given this, it seems to me like I don't care about whatever new wrinkles ADO.NET might have regarding data access.  My old "ResultSets" should work just fine.  (This is for the "back-end processing only.  The UI for my app is a different story, to be covered in a later question.)

So I have two questions:  Do you think my previous paragraph is true?  And if so, what is the closest corollary C# has to a Java "ResultSet"?

Thanks again!
--BrianMc1958
0
Comment
Question by:BrianMc1958
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 12

Assisted Solution

by:gbzhhu
gbzhhu earned 200 total points
ID: 16543693

Your statement according to me is correct.  Your situation doesn't call for disconnected data access (simplistically explained here for your reference  
http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson05.aspx

The closest object in .NET to resultset is to be Command object (SQLCommand)
0
 

Author Comment

by:BrianMc1958
ID: 16543699
BTW: I ask this in particular because the VS2005 "Java-to-C# Converter" converted my ResultSet objects to OleDbDataReader objects.  Should I trust it?
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 800 total points
ID: 16543705
The C# equivalent would be the SqlDataReader (or OleDbDataReader etc depending on your DB).

The DataReader is a connected result set. The downside is that it is a forward-only result set, which may or may not be suitable for your needs.

If you need more than forward-only access then you are stuck with a disconnected DataSet.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:Fahad Mukhtar
ID: 16543752
>>What C# object is closest to Java ResultSet?

It is DataReader which is connected, forward only ,read only data object
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16543800
I read ResultSet as Recordset, so please ignore my comment and I agree with others DataReader it is
0
 

Author Comment

by:BrianMc1958
ID: 16543807
To gbzhhu: Thanks for the link.  It's really great.  I'm reading the whole thing.  Then maybe I won't have to bother you all so much.

To everybody:  As a (brand)newbie, I can't tell which of you is right.  gbzhhu says SqlCommand, and carl tawn and Desp say DataReader (which the VS2005 Java Converter agrees with.)  I'm going to study gbzhhu's ADO link before awarding points, unless maybe you folks could clear this up for me.

Thanks again,
BrianMc1958  
0
 

Author Comment

by:BrianMc1958
ID: 16543819
To everybody:  The previous two posts crossed in the mail.  Got it now!  Thanks again!
--BrianMc1958
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16543822
The SqlCommand object doesn't contain any data. It is used to store and execute commands on a connection that return data.
0
 

Author Comment

by:BrianMc1958
ID: 16543825
BTW: Would like to award some points just for the great ADO link.  I really needed it...
0
 

Author Comment

by:BrianMc1958
ID: 16543854
BTW #2:  I assume when two people give me the same correct answer, I'm supposed to award all the points to the first one?  Is that right?  Or am I supposed to split points?  I would hate to insult someone who's taking the time to help me out!
--BrianMc1958
0
 
LVL 12

Expert Comment

by:gbzhhu
ID: 16543935
BrianMc1958

As far as I know there are no hard rules when 2 people give 2 similar answers.  You could accept the first one or split.  What I normally do is split but offer the first expert to answer a little more say 60% to expert who answered first and 40% for the other.  Either approach is fine with most experts.  
0
 

Author Comment

by:BrianMc1958
ID: 16543956
OK.  Thanks...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question