Discussion:
256 Character Limit on Edit Box Control/ODBC MFC App
(too old to reply)
Steve Hume
2004-05-14 11:51:04 UTC
Permalink
Hi

I’m developing a SDI project that allows a user to edit text in a MSSQL7 database table. This is achieved via ODBC through an edit box control. I'm using Visual C++ 6 on Windows 2000 Server, but will shortly be carrying on the project on NT4 workstatio

The data type on the db field is varchar (2000) and the VC++ member variable type for the edit control is CString value with validation - again 2000 characters

However I've found that whenever over 256 characters are entered an error is returned i.e:

'Please enter no more than 256 characters.

Using the debugger I've traced the error back to a validation routine that starts on line 254 of DBVIEW.CPP. The function in question is void AFXAPI DDX_FieldText where a call to CString::GetAllocLength is tested against the actual length of the string in the edit control. There is a rather cryptic comment above this bit of code which reads:

'// check if length is too long (this is complicated by Windows NT/J)

Has anyone got any ideas on this or how to get round the problem? I find it rather difficult to believe that it has not been encountered before and yet I can find no reference to it on the MSDN Knowledge Base. The closest was a reference to a bug on Visual C++ 4 where ''Please enter no more than 0 characters' was returned when using the same function in a DAO context (Daview.cpp)

Many Thank

Steve Hum
Yasoo
2004-05-14 12:26:05 UTC
Permalink
Isn't it because the limit of a text field in the database? You can use a memo field.
Steve Hume
2004-05-17 08:16:04 UTC
Permalink
Yasso

varchar and text are SQL datatypes. They are the datatypes that I've tried on the column of the table concerned. varchar will only use the amount of space needed with an upper limit of 2000 characters and is the one I eventually decided on. The datatype that I'm using on the MFC side is CSTRING and I specified a 2000 limit on the Wizard

Thanks Again..Stev
Aleksandar Vukelja
2004-05-15 19:55:18 UTC
Permalink
Hi
I’m developing a SDI project that allows a user to edit text in a MSSQL7 database table. This is achieved via ODBC through an edit box control. I'm using Visual C++ 6 on Windows 2000 Server, but will shortly be carrying on the project on NT4 workstation
The data type on the db field is varchar (2000) and the VC++ member variable type for the edit control is CString value with validation - again 2000 characters.
However I've found that whenever over 256 characters are entered an error is returned i.e: -
'Please enter no more than 256 characters.'
Using the debugger I've traced the error back to a validation routine that starts on line 254 of DBVIEW.CPP. The function in question is void AFXAPI DDX_FieldText where a call to CString::GetAllocLength is tested against the actual length of the string in the edit control. There is a rather cryptic comment above this bit of code which reads: -
'// check if length is too long (this is complicated by Windows NT/J)'
Has anyone got any ideas on this or how to get round the problem? I find it rather difficult to believe that it has not been encountered before and yet I can find no reference to it on the MSDN Knowledge Base. The closest was a reference to a bug on Visual C++ 4 where ''Please enter no more than 0 characters' was returned when using the same function in a DAO context (Daview.cpp).
Many Thanks
Steve Hume
If you are using a CRecordset derived class to access your database,
you're problem is probably default text length of RFX_Text function.
Look at DoFieldExchange function in your .cpp file.

Just add desired length, i.e. if Class Wizard generated
RFX_Text(pFX, _T("[ColumnName]"), m_ColumnName);

change it into RFX_Text(pFX, _T("[ColumnName]"), m_ColumnName, 2000);

It's strange that the same default limit is defined also for RFX_Binary,
which is typically used for storing pictures.



Aleksandar Vukelja
Steve Hume
2004-05-17 08:26:02 UTC
Permalink
Aleksanda

This sounds like it is probably the answer that I'm looking for

I'll try it tomorrow, as I'm doing other stuff, today and let you know

Many Thanks

Steve Hume
Steve Hume
2004-05-19 12:01:04 UTC
Permalink
Aleksandar

Your solution worked!

Than you!

Steve Hume

Loading...