Solved

Convert DataTable to DataReader

Posted on 2010-11-30
11
2,396 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
[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
  • 4
  • 2
  • 2
  • +2
11 Comments
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 166 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
Independent Software Vendors: 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 83

Accepted Solution

by:
CodeCruiser earned 167 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 167 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

Independent Software Vendors: 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

Suggested Solutions

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 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