I am new to C#, having done quite a bit of coding in VB6 in the past.
I would like some advice on displaying data from a SQL database in a grid in a C# Windows Forms program. I have seen lots of ways to do this but I don’t want to learn an obsolete method, so wondered if anyone could help.
The way I preferred to do this when I used VB6 was:
MS Access DB -> ODBC -> ADOConnection -> RecordSet -> MSFlexGrid
I have seen the DataGridView in C# but don’t think this is the method I would prefer. That seems to be linked to a data source at design time, whereas the MSFlexGrid in VB6 was programatically populated at run time. (I apologise if I have got this wrong).
Basically, the perfect answer to this query would be link(s) to:
- A simple data access tutorial.
- A round-up of all ways to display information in a grid.
Use connection, and dataadapter class to fill DataTable. Then simply bind it to the gird by using DataSource property of the grid.
When creating a new instance of dataadapter, in parentheses define the sql query (select from ).
It should look simply like