L
Landon
Hi I use Visual C++ MFC 4.2.
I need to get the last support_code from the table so I make query like this:
CString sSQL;
sSQL.Format( "SELECT MAX( support_no ) AS \"last\" FROM history WHERE
support_no LIKE \'%s*\'", sYear );
I have tested it in the MS Access and it worked fine.
It should return Support Code in the form like this: "S08-00012" so it has S
and - characters inside.
Now. the problem is from the programming side.
rs.Open( CRecordset::forwardOnly, ( sSQL ) );
CString sSupportNo;
CString sNextCounter;
if( !rs.IsEOF() ){
rs.GetFieldValue( "last", varSupportNo );
ASSERT( varSupportNo.m_dwType == DBVT_STRING );
sSupportNo = *varSupportNo.m_pstring;
}
The error is at the ASSERT part. I know the error but I don't know how to
fix it.
The point is that the value of field "last" is not a CString. I don't know
what it is, because I also have tried DOUBLE type it neither work.
What is the return value of MAX to my code?
Thank you very much.
I need to get the last support_code from the table so I make query like this:
CString sSQL;
sSQL.Format( "SELECT MAX( support_no ) AS \"last\" FROM history WHERE
support_no LIKE \'%s*\'", sYear );
I have tested it in the MS Access and it worked fine.
It should return Support Code in the form like this: "S08-00012" so it has S
and - characters inside.
Now. the problem is from the programming side.
rs.Open( CRecordset::forwardOnly, ( sSQL ) );
CString sSupportNo;
CString sNextCounter;
if( !rs.IsEOF() ){
rs.GetFieldValue( "last", varSupportNo );
ASSERT( varSupportNo.m_dwType == DBVT_STRING );
sSupportNo = *varSupportNo.m_pstring;
}
The error is at the ASSERT part. I know the error but I don't know how to
fix it.
The point is that the value of field "last" is not a CString. I don't know
what it is, because I also have tried DOUBLE type it neither work.
What is the return value of MAX to my code?
Thank you very much.