Click here to Skip to main content
15,886,074 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why i crash on call the function wcscpy_s ??? ( what wrong with my code ?) Pin
Mark Salsbery12-Oct-07 7:51
Mark Salsbery12-Oct-07 7:51 
AnswerRe: Why i crash on call the function wcscpy_s ??? ( what wrong with my code ?) Pin
led mike12-Oct-07 7:51
led mike12-Oct-07 7:51 
GeneralRe: Why i crash on call the function wcscpy_s ??? ( what wrong with my code ?) Pin
Mark Salsbery12-Oct-07 7:55
Mark Salsbery12-Oct-07 7:55 
QuestionEnableTheming(TRUE) Pin
bob1697212-Oct-07 4:47
bob1697212-Oct-07 4:47 
QuestionVisual Styles and Toolbar Pin
bob1697212-Oct-07 3:31
bob1697212-Oct-07 3:31 
Questiona problem about stackoverflow Pin
nibabug12-Oct-07 3:29
nibabug12-Oct-07 3:29 
QuestionRe: a problem about stackoverflow Pin
David Crow12-Oct-07 3:44
David Crow12-Oct-07 3:44 
AnswerRe: a problem about stackoverflow Pin
nibabug12-Oct-07 3:51
nibabug12-Oct-07 3:51 
get data from three different tables , and then do something , and then show them, look the flowing:
void CSerialRecieveDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CString strSql;
// int m=atoi(m_strNum);
_variant_t var;
CString str,strnum;
CString strSendFW,strSendFY,strSendQX;
CString strSend;

str="";

SQLNum++;
if(SQLNum==130)
SQLNum-=129;
strSql.Format("%d",SQLNum);
strnum=strSql;
strSql.Format("SELECT * FROM TB_FANGWEI WHERE ID = '%s'",strnum);


try
{
//先关闭已经打开的记录集对象
m_pRecordset->Close();

//根据新的Sql查询语句,重新打开记录集对象
m_pRecordset->Open(strSql.AllocSysString(),
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}


//在ADO操作中建议语句中要常用try...catch()来捕获错误信息,
//因为它有时会经常出现一些想不到的错误。
var = m_pRecordset->GetCollect("Value");
if(var.vt != VT_NULL)
str = (LPCSTR)_bstr_t(var);
m_strAGFW=str;
var = m_pRecordset->GetCollect("HexValue");
if(var.vt != VT_NULL)
str = (LPCSTR)_bstr_t(var);
strSendFW=str;
// char* pszTest = (char*)(LPCTSTR)strSendFW;
// unsigned char* ptr=(unsigned char*)pszTest;
// unsigned char uchartemp;
// unsigned char m=4;
unsigned int intFW=(unsigned int)_tcstoul(strSendFW, 0, 16);
intFW&=0x3fff;
intFW<<=2;
intFW|=0x0000;

strSql.Format("SELECT * FROM TB_FUYANG WHERE ID = '%s'",strnum);

try
{
//先关闭已经打开的记录集对象
m_pRecordset->Close();

//根据新的Sql查询语句,重新打开记录集对象
m_pRecordset->Open(strSql.AllocSysString(),
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}

var = m_pRecordset->GetCollect("Value");
if(var.vt != VT_NULL)
str = (LPCSTR)_bstr_t(var);
m_strAGFY=str;
var = m_pRecordset->GetCollect("HexValue");
if(var.vt != VT_NULL)
str = (LPCSTR)_bstr_t(var);
strSendFY=str;
unsigned int intFY=(unsigned int)_tcstoul(strSendFY, 0, 16);
intFY&=0x3fff;
intFY<<=2;
intFY|=0x0001;


SQLNumQX++;
if(SQLNumQX==458)
SQLNumQX-=457;
strSql.Format("%d",SQLNum);
strnum=strSql;

strSql.Format("SELECT * FROM TB_QINGXIE WHERE ID = '%s'",strnum);

try
{
//先关闭已经打开的记录集对象
m_pRecordset->Close();

//根据新的Sql查询语句,重新打开记录集对象
m_pRecordset->Open(strSql.AllocSysString(),
theApp.m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}

var = m_pRecordset->GetCollect("Value");
if(var.vt != VT_NULL)
str = (LPCSTR)_bstr_t(var);
m_strAGQX=str;
var = m_pRecordset->GetCollect("HexValue");
if(var.vt != VT_NULL)
str = (LPCSTR)_bstr_t(var);
strSendQX=str;

unsigned int intQX=(unsigned int)_tcstoul(strSendQX, 0, 16);
intQX&=0x3fff;
intQX<<=2;
intQX|=0x0002;

strSend="";
// strSend+="$";
str.Format("%4x",intFW);
strSend+=str;
str.Format("%4x",intFY);
strSend+=str;
str.Format("%4x",intQX);
strSend+=str;

// CString m_str;
unsigned int crc;
unsigned char* ptr;
unsigned char len;

str=strSend;
char* pszTest = (char*)(LPCTSTR)str;

ptr=(unsigned char*)pszTest;
len=str.GetLength();


crc=0;
crc=ban_crc(ptr,len);//计算校验值
strSend.Format("$");
strSend+=str;
// str=m_sSendData;
// m_str+=str;
str.Format("*");
strSend+=str;

str.Format("%04x",crc);
strSend+=str;
m_ctrlMSCommCOM1.SetOutput(COleVariant(strSend));//发送数据



UpdateData(FALSE);

// m_AccessList.AddString( strName + " --> "+strAge );

// m_pRecordset->MoveNext();

CDialog::OnTimer(nIDEvent);
}


wuhuaiji

GeneralRe: a problem about stackoverflow Pin
David Crow12-Oct-07 3:56
David Crow12-Oct-07 3:56 
GeneralRe: a problem about stackoverflow Pin
toxcct12-Oct-07 4:36
toxcct12-Oct-07 4:36 
QuestionRe: a problem about stackoverflow Pin
David Crow12-Oct-07 4:43
David Crow12-Oct-07 4:43 
AnswerRe: a problem about stackoverflow Pin
toxcct12-Oct-07 4:47
toxcct12-Oct-07 4:47 
AnswerRe: a problem about stackoverflow Pin
nibabug12-Oct-07 4:11
nibabug12-Oct-07 4:11 
GeneralRe: a problem about stackoverflow Pin
David Crow12-Oct-07 4:32
David Crow12-Oct-07 4:32 
GeneralRe: a problem about stackoverflow Pin
Mike Dimmick12-Oct-07 6:10
Mike Dimmick12-Oct-07 6:10 
GeneralRe: a problem about stackoverflow Pin
nibabug12-Oct-07 15:24
nibabug12-Oct-07 15:24 
AnswerRe: a problem about stackoverflow Pin
Jonathan [Darka]12-Oct-07 3:44
professionalJonathan [Darka]12-Oct-07 3:44 
QuestionMonitor hard drive light via a C++ program in Windows XP Pin
isikorsky9112-Oct-07 3:22
isikorsky9112-Oct-07 3:22 
QuestionRe: Monitor hard drive light via a C++ program in Windows XP Pin
David Crow12-Oct-07 3:43
David Crow12-Oct-07 3:43 
AnswerRe: Monitor hard drive light via a C++ program in Windows XP Pin
isikorsky9112-Oct-07 3:48
isikorsky9112-Oct-07 3:48 
GeneralRe: Monitor hard drive light via a C++ program in Windows XP Pin
David Crow12-Oct-07 3:54
David Crow12-Oct-07 3:54 
GeneralRe: Monitor hard drive light via a C++ program in Windows XP Pin
isikorsky9112-Oct-07 5:16
isikorsky9112-Oct-07 5:16 
GeneralRe: Monitor hard drive light via a C++ program in Windows XP Pin
David Crow12-Oct-07 5:24
David Crow12-Oct-07 5:24 
GeneralRe: Monitor hard drive light via a C++ program in Windows XP Pin
isikorsky9112-Oct-07 8:24
isikorsky9112-Oct-07 8:24 
GeneralRe: Monitor hard drive light via a C++ program in Windows XP Pin
David Crow12-Oct-07 8:42
David Crow12-Oct-07 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.