0

I've a dataset with a table and I want to copy these values to sqldatareader. Is there any way to do this in C#?

I tried with ds.CreateDataReader(); but it is returning DataTableReader and not SQLDataReader.

Can someone tell me how to get it done?

1
  • Why do you need a SQLDataReader? Can you use the DbDataReader class that both inherit from? Commented Mar 5, 2014 at 14:55

2 Answers 2

2

You can't copy data to a data reader, because the data reader doesn't contain any data in itself, it reads from a data source.

Each data reader reads from a specific data source, so for an SqlDataReader the data source would be an SQL Server database, not a DataSet object.

So, what you are specifically asking for is not possible. If you can use the DbDataReader base class instead of specifically the SqDataReader class, then you can use any data reader.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I'll try this. I think this will solve my problem.
0

A SQLDataReader is for reading data from SQL Server, not from a DataSet - you'd have to get the original SQL query that was used to populate the dataset and re-query the server.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.