我试过,我的可以啊,不过我是将其显示在表格中。
int CVICALLBACK ReadCB (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int i=0
long meas1Stat
int hmap
int hstmt
int resCode
char num[50]
switch (event)
{
case EVENT_COMMIT:
hdbc=DBConnect ("DSN=BinTestCVIUID=××PWD=××××")
if(hdbc<=0)
{
MessagePopup ("Connect", "cann't connect to the data source!")
return 0
}
else
{
MessagePopup ("Connect", "Successfully connect to the data source!")
}
hmap= DBBeginMap(hdbc)
DBMapColumnToChar (hmap, "NAME", 11, num,&meas1Stat,"")
// DBMapColumnToChar(hmap, "名称", 11,serialNum, &sNumStatus,"")
//hstmt = DBActivateMap(hmap, "参数表")
hstmt=DBActivateMap(hmap,"table1")
while ( DBFetchNext(hstmt)==0)
{
InsertTableRows (panelHandle, PANEL_TAB_RESULTS, -1, 1, VAL_CELL_STRING)
SetTableCellVal (panelHandle, PANEL_TAB_RESULTS, MakePoint(3,i+1), num)
i++
}
break
}
return 0
}
程序语法没问题,是不是你数据库的数据类型和你程序变量类型不匹配,或其它逻辑错误。
另外”while ( DBFetchNext(hstmt)==0)“ 每执行一次DBFetchNext(hstmt),将你表格中的一行记录中你绑定的列的值给你绑定的变量,所以你的字符串char serialNum[11]最终的值是你表格中的最后一行记录中你绑定的列的值。
1.在ODBC中配置数据源2.ConnectHandle=DBConnect ("DSN=CVILocalUID=saPWD=123")
ActivateHandle= DBActivateSQL (ConnectHandle, "select * from 标志位表")
while(DBFetchNext(ActivateHandle)==DB_SUCCESS)
{
DBGetColVariant (ActivateHandle, 2, &TempInt)
CA_VariantConvertToType (&TempInt, CAVT_INT, &StartMarkInt)
}
DBDeactivateSQL (ActivateHandle)
DBDisconnect (ConnectHandle)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)