?
Solved

Can I use ADO and disconnected recordsets in C#

Posted on 2008-10-27
7
Medium Priority
?
557 Views
Last Modified: 2012-05-05
I am a big fan of ADO recordsets in the old VB6 world.  I load them with data, save them as files and then reload them.  They are a wonderful say of saving settings.  I also iterate through them to load data into grids to display to the user.  I am not a big fan of having a grid bound to the database.

So - can I do this in C#?  I am writing my first C# doofer that has a UI ( all the others I did were very simple web services).  

Thanks in advance.

Todd
0
Comment
Question by:toddism
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Expert Comment

by:Blackninja2007
ID: 22812331
ADO.NET can work disconnected ... indeed it does alot disconnected.
0
 
LVL 3

Expert Comment

by:Blackninja2007
ID: 22812339
.... just create a  Dataset ... then close the connection.
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 22812376
To save to and load from a file, use Dataset.WriteXml() and Dataset.ReadXml()

Dataset is really a lot more powerful than recordset, once you get to know it.
0
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.

 

Author Comment

by:toddism
ID: 22812414
jcoehoorn: can I create datasets dynamically?  append fields, etc then iterate through it?  
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 22812535
Sure.

DatasSt ds = new DataSet();
DataTable dt = ds.Tables.Add();
 
dt.Columns.Add("MyColumn1");
dt.Columns.Add("MyColumn2");
 
dt.Rows.Add(new object[] {"value1","value2"});
dt.Rows.Add(new object[] {"value3", value4"});
 
foreach (DataRow row in dt.Rows)
{
    Console.WriteLine("New Row:");
    foreach (DataColumn col in dt.Columns)
    {
        Console.WriteLine("\t" + col.ColumnName + ": " + row[col].ToString());
    }
}

Open in new window

0
 
LVL 18

Accepted Solution

by:
jcoehoorn earned 1000 total points
ID: 22812541
Oops: missed a double quotes in that snippet.

DatasSt ds = new DataSet();
DataTable dt = ds.Tables.Add();
 
dt.Columns.Add("MyColumn1");
dt.Columns.Add("MyColumn2");
 
dt.Rows.Add(new object[] {"value1","value2"});
dt.Rows.Add(new object[] {"value3", "value4"});
 
foreach (DataRow row in dt.Rows)
{
    Console.WriteLine("New Row:");
    foreach (DataColumn col in dt.Columns)
    {
        Console.WriteLine("\t" + col.ColumnName + ": " + row[col].ToString());
    }
}

Open in new window

0
 

Author Closing Comment

by:toddism
ID: 31510281
Excellent answer.  Exactly what I was looking for.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

764 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