[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Convert DataTable to DataReader

Posted on 2010-11-30
11
Medium Priority
?
2,860 Views
Last Modified: 2012-05-10
I am looking for a snippet of code which converts a DataTable to a DataReader in vb.net.
0
Comment
Question by:Howard Bash
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 664 total points
ID: 34239176
What exactly do you want to do ? Read the datatable line by line ?

I don't think you can convert this. You'll need to change your implementation/desgin.

Datatable vs datareader
http://social.msdn.microsoft.com/Forums/en/adodotnetdataproviders/thread/a9104d3e-0736-433c-b403-39a33ac76d2d
0
 
LVL 1

Author Comment

by:Howard Bash
ID: 34239306
I have seen such code and am building a set of conversion functions and wanted to include this.
0
 
LVL 18

Expert Comment

by:deighton
ID: 34239480
a DataReader provides different functionality to a DataTable - a DataTable is a cache of data in memory, but a DataReader accesses data row-by-row.

A DataReader can sometimes be considered to be a performance saving over a DataTable, but its implementation has to be correctly designed into the code.  I'd be surprised if anyone had designed code to perform this for you automatically in a beneficial way.

But good luck!
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
LVL 83

Accepted Solution

by:
CodeCruiser earned 668 total points
ID: 34243049
You can create a DataTableReader using the CreateDataReader function

http://msdn.microsoft.com/en-us/library/system.data.datatable.createdatareader%28v=VS.90%29.aspx
0
 
LVL 1

Author Comment

by:Howard Bash
ID: 34278237
The url shows me how to make a dataReader from a datatable which is fine.  Unfortuanetly,  I cannot directly convert a DataReader to MySqlDataReader.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34281316
That is how it works. You can not convert a DataTable to a SQLDataReader. The SQLDataReader has to connect to a SQL Server DB.
0
 
LVL 18

Expert Comment

by:deighton
ID: 34281718
so are you using MYSQL?  Is that the problem here, you want to know how to access MySql data?
0
 
LVL 1

Author Comment

by:Howard Bash
ID: 34307507
I'm okay with accessing the data.  It's creating a MySQLDataReader from a datatable that I am struggling with.
0
 
LVL 22

Assisted Solution

by:JesterToo
JesterToo earned 668 total points
ID: 34507535
You cannot create a MySQLDataReader from a DataSet or a DataTable... what you probably need is a DataTableReader.  a MySQLDataReader reads its data directly from a MySQL Connection (the database itself) and a DataTableReader reads its data from a .Net object (i.e. a DataTable).  There are many examples of creating/using a DataTableReader on the web but if you need a specific example just let us know.  BTW, a DataTableReader is a .net class and is not specific to any flavor of db.
0
 
LVL 1

Author Closing Comment

by:Howard Bash
ID: 34674800
FIne explainations and useful links for further investingation.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
How much do you know about the future of data centers? If you're like 50% of organizations, then it's probably not enough. Read on to get up to speed on this emerging field.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

873 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