Solved

Convert DataTable to DataReader

Posted on 2010-11-30
11
2,142 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:hbash
  • 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:hbash
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
 
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:hbash
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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:hbash
ID: 34307507
I'm okay with accessing the data.  It's creating a MySQLDataReader from a datatable that I am struggling with.
0
 
LVL 21

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:hbash
ID: 34674800
FIne explainations and useful links for further investingation.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Has anyone used domo? 1 39
VB.NET HttpWebRequest 12 30
Closing all open child forms. 4 22
Saveas need to save a copy 16 0
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now