开发者

C# datatable, dictionary, datagridview

开发者 https://www.devze.com 2023-01-05 20:19 出处:网络
I have a project where I want to: 1) grab data from a sql server database, 2) pull the data into a c# program,

I have a project where I want to:

1) grab data from a sql server database,

2) pull the data into a c# program,

3) keep the data persistent - (store in a dictionary?)

4)view the data using a datagridview,

5) update the data, which would update the datagridview, the dictionary, and the database

What would be the most efficient way to implement this project?

My current thinking is to use a datatable to keep data persistent in program开发者_运维问答, and to allow data to be easily viewable. As well.

Any thoughts?


You can bind a DataGridView directly to a datasource (SQL Server) as described here


Create DBML, and use LinQ. Get your data, and bind them to custom DataTable (which is created with your own column names, types etc.) Bind your DataTable to gridView. Put a Update button, and when user selects a row, clicks an update button, get selected row, Update this row with LinQ and refresh your gridView.


phsr's answer takes care of the UI and database. In order to store it locally you could use a SQL Express database, or an easy alternatively would be to simply store it in local XML files, see here for some help with that:

http://msdn.microsoft.com/en-us/library/fx29c3yd.aspx

Hope that helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消