Barry Dunlap
asked on
Dataset to c# class
I have a C# class in Visual Studio 2017 to hold values for columns of a SQL Server 2014 table. I have a DataSet returned from a stored proc. Can please you send a code sample that puts the values for each table column from the DataSet into the class that has corresponding names. If you want the code for the class I can send it.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, Kyle. I will copy this code to my project and see have it work. I will have to adjust it to my column names, etc. but it appears to be what I need. Thanks for responding quickly as I need to have this working now.
Barry Dunlap
Barry Dunlap
ASKER
Kyle, thanks for the link you sent. That is very helpful and complete with code samples.
Barry.
Barry.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Vadim,
I read what you wrote. Very helpful. Also, thanks for the links to Docs. I am working through issues with a database table and a 7-table join stored proc. It has caused trouble with how a two DataGridView controls are filled. I did use adapter.fill(datatable) as you recommended, but the DataGridView did not fill. I'll keep working on it as I probably missed something. If I can't fix it, I probably should send a file with code so you can see my error.
Barry
I read what you wrote. Very helpful. Also, thanks for the links to Docs. I am working through issues with a database table and a 7-table join stored proc. It has caused trouble with how a two DataGridView controls are filled. I did use adapter.fill(datatable) as you recommended, but the DataGridView did not fill. I'll keep working on it as I probably missed something. If I can't fix it, I probably should send a file with code so you can see my error.
Barry
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://exceptionnotfound.net/mapping-datatables-and-datarows-to-objects-in-csharp-and-net-using-reflection/
Essentially you can build a mapping class and use reflection to bind columns to properties.