Convery DataTable to Strongly typed dataset.

I have a problem, whne i try to convert a standard DataTable object to a Strongly typed DataTable  (Datatable belongs to a strongly typed dataset) and both tables have the same schema. here is the code the code:

TypedDataSet.TypeDataTable ResultTable = (TypedDataSet.TypeDataTable)GetStandartTable(MySqlString);

I get  " Specified cast is not valid."

any idea on how can i convert or even copy all the info between the two tables?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Well, your original table is of type DataTable and you are trying to cast the type, which is a problem with type casting. The fact that the two tables have the same schema is irrelevant.

What you can do is copy all data, but this will be a slow operation. The code would be:

TypedDataSet.TypeDataTable ResultTable = new TypedDataSet.TypeDataTable();
foreach (DataRow row in GetStandartTable(MySqlString))
    ResultTable.ImportRow (row);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.