怎样在在SQL语句中实现变量查询?我在论坛等了一天的答案了,还是没人知道!!!!!!
用ADO:
m_pRecordset->Open("SELECT * FROM TestDataTable WHERE [Sr]=m_eSr", theApp.m_pConnection.GetInterfacePtr(),adOpenDynamic,
adLockOptimistic,adCmdText);
m_eSr为我定义的double型变量,其值实时改变。编译没有错误,运行的时候会出现这个错误对话框:
Runtime Error!
Program:D:\DBProg\Debug\DBProg.exe
This application has requested the Runtime to
terminate it in an unusual way.Please contact the
applicatuion's support team for more nformation
但是如果把m_eSr换成"SELECT * FROM TestDataTable WHERE Sr=0.45"就可以。我想可能是变量的问题,我把语句换成了"SELECT * FROM TestDataTable WHERE Sr=m_eSr"也不行,跟SELECT * FROM TestDataTable ORDER BY ABS(TSR-[Sr])一样,所以是不是SQL语句的格式写错了?