I'm using the MFC ODBC consumer wizard to create my CRecorset derived class to bind fields of my SQL Server table.
But at run-time at rs->Open(...) line, it launches a Debug Assertion Failed message.
I already realized that it is about of having a char(500) field in my table. That is the cause!
And I read somewhere that MFC allows binding to less than 256 characters length by default.
Is there any way or any function that I can call before the Open function to set as maximum length to 500 for the binding ?
Here's some code:
in SQL Server I have my TABLE:
----------------------------------
id int
my_string char(500)
in Visual Studio I have this class generated by the wizard:
---------------------------------------------------------------
class CMyClassRS : public CRecordset
{
public:
CMyClassRS(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(CMyClassRS)
int m_id;
CStringA m_my_string;
........
and in my main:
-----------------
....
CMyClassRS *rs = new CMyClassRS();
rs->Open(CRecordset::snapshot,"select * from TABLE");
Character data beyond 255 characters is truncated by default when mapped to CString. You can extend the truncation length by explicitly setting the nMaxLength argument of RFX_Text.