Solved

Convert DataTable to DataReader

Posted on 2010-11-30
11
2,536 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
Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 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