Last week I posted a new version of MFC Grid Control which worked with database; I've changed the source code,and sub class it from
CGridCtrl, and also deleted some extra code. So this is the new version.
Creating this control is the same as MFC grid exept that when you want to define variable grid, you have to define it with
CGridCtrl. You have to import msado15.dll to your project too. In yout stdafx.h, you can write domething like this:
#import "E:\Program Files\Common Files\System\ado\msado15.dll"
no_namespace rename( "EOF", "adoEOF" )
Here is the rest of information about this grid:
I've tested this grid with most of SQLServer data types, so I think it will work with most of them except
uniqueidentifier. The same thing was found for MS-Access database, but I don't think these caused a lot of trouble, because these are not very common types for displaying in grid. Maybe I'll add these features later to my grid. Also if somebody wants to do it, he/she can mail new version to me, and I'll update source code. After all it is not FULLY tested and maybe there are some bugs in it.
How to use?
Simple. Just after you create grid like the way it is said in MFC Grid article, give datasource and sqlstring to it, then use
FillGrid() functions like this:
m_gridctrl.m_strDataSource = "Provider=Microsoft.Jet.OLEDB.4.0;"
m_gridctrl.m_strQuery = "select * from Table1";
That's it. It reads datasource and fills up the grid. Then if the grid is not in readonly mode, if user edits a cell, it will automaticlly update database; also if you select row(s) and press DELETE key, it will delete records from both database and grid.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.