gd2
gd2

Reputation: 21

C# datatable, dictionary, datagridview

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?

Upvotes: 0

Views: 980

Answers (3)

Kieren Johnstone
Kieren Johnstone

Reputation: 42003

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!

Upvotes: 0

Serkan Hekimoglu
Serkan Hekimoglu

Reputation: 4284

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.

Upvotes: 0

Dan McClain
Dan McClain

Reputation: 11920

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

Upvotes: 2

Related Questions