#include "MSDATGRD.h"//数据库表格控件头文件
#include "ADODB.h"//ADO2.7头文件
#include cvirte.h
#include cviauto.h
#include "ADOToolkit.h"//菜农封装的ADO
#include userint.h
#include "test.h" //ADO测试程序头文件
#include formatio.h
static int panelHandle;
static CAObjHandle DataGrid1;
static CAObjHandle DataGrid2;
int main (int argc, char *argv[])
{
static HRESULT status;
int DataBase, Table1, Table2;
CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED);
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "test.uir", PANEL)) < 0)
return -1;
GetObjHandleFromActiveXCtrl (panelHandle, PANEL_DATAGRID_1, &DataGrid1);//数据库表格控件1
GetObjHandleFromActiveXCtrl (panelHandle, PANEL_DATAGRID_2, &DataGrid2);//数据库表格控件2
ADO_DataBaseInit ();//ADO初始化
status = ADO_OpenDataBase ("DSN=SampleDatabase", &DataBase);//打开数据库
if (status == S_OK)
{
status = ADO_OpenTable ("SELECT * FROM [myTable]", &Table1);//用SQL语句打开表1
if (status == S_OK)
{
status = ADO_OpenTable ("myOtherTable", &Table2);//直接打开表2
if (status == S_OK)
{
ADO_DataGrid (DataGrid1, Table1);//将Table1绑定到DataGrid1
ADO_DataGrid (DataGrid2, Table2);//将Table2绑定到DataGrid2
}
}
}
DisplayPanel (panelHandle);
RunUserInterface ();
ADO_DataBaseQuit ();//ADO退出(自动关闭数据库及表和释放系统资源)
DiscardPanel (panelHandle);
return 0;
}
哈哈~~~准备进一步完善,肯定比$598的SQL Toolkit好玩,快捷~~~
刚刚做CVI的函数面板菜鸟,准备继续完善.
要没有此功能,真该要倒塌了~~~
用户1339183 2008-7-1 11:05
用户64510 2007-11-13 16:36
请教个问题:在CVI里我咋才能把数据以记录格式保存在Access里呢?
用的是Mircosoft ADO2.7Libra