And here I thought that was obvious :)Quote:
Originally posted by souldog
I think the point of Mick's post is it is very unlikely that the CString
is really 2.1G so something else must be going on.
Printable View
And here I thought that was obvious :)Quote:
Originally posted by souldog
I think the point of Mick's post is it is very unlikely that the CString
is really 2.1G so something else must be going on.
You may try:Quote:
How do you create your string??
Good luck!Code:CString str( _T('A'), INT_MAX-1 );
However:
2,147,352,576 == unreserved virtual memory (accessible by a process (NT)).
2,147,483,646 == INT_MAX - 1
Also I think, we are on a wrong path.
wangnanjing, would you, please, clarify your problem?
I don't know how that would help if the length is really exceeded.Quote:
Originally posted by irona20
How do you create your string??
If it is something like this:
CString str = "very huge string";
you can do the following:
CString str = "string shorter";
str += "the rest of the string";
In fact this seems interesting. Consider this code for CString
So what happens if the sum of the lengths exceeds the size of int?PHP Code:// NOTE: "operator+" is done as friend functions for simplicity
// There are three variants:
// CString + CString
// and for ? = TCHAR, LPCTSTR
// CString + ?
// ? + CString
void CString::ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data,
int nSrc2Len, LPCTSTR lpszSrc2Data)
{
// -- master concatenation routine
// Concatenate two sources
// -- assume that 'this' is a new CString object
int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen != 0)
{
AllocBuffer(nNewLen);
memcpy(m_pchData, lpszSrc1Data, nSrc1Len*sizeof(TCHAR));
memcpy(m_pchData+nSrc1Len, lpszSrc2Data, nSrc2Len*sizeof(TCHAR));
}
}
CString AFXAPI operator+(const CString& string1, const CString& string2)
{
CString s;
s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData,
string2.GetData()->nDataLength, string2.m_pchData);
return s;
}
here
Am I seeing thingsPHP Code:int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen != 0)
{
AllocBuffer(nNewLen);
Speculation :) I'd like to see what is going on first....Quote:
Originally posted by souldog
I don't know how that would help if the length is really exceeded.
In fact this seems interesting. Consider this code for CString
So what happens if the sum of the lengths exceeds the size of int?PHP Code:// NOTE: "operator+" is done as friend functions for simplicity
// There are three variants:
// CString + CString
// and for ? = TCHAR, LPCTSTR
// CString + ?
// ? + CString
void CString::ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data,
int nSrc2Len, LPCTSTR lpszSrc2Data)
{
// -- master concatenation routine
// Concatenate two sources
// -- assume that 'this' is a new CString object
int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen != 0)
{
AllocBuffer(nNewLen);
memcpy(m_pchData, lpszSrc1Data, nSrc1Len*sizeof(TCHAR));
memcpy(m_pchData+nSrc1Len, lpszSrc2Data, nSrc2Len*sizeof(TCHAR));
}
}
CString AFXAPI operator+(const CString& string1, const CString& string2)
{
CString s;
s.ConcatCopy(string1.GetData()->nDataLength, string1.m_pchData,
string2.GetData()->nDataLength, string2.m_pchData);
return s;
}
here
Am I seeing thingsPHP Code:int nNewLen = nSrc1Len + nSrc2Len;
if (nNewLen != 0)
{
AllocBuffer(nNewLen);
thank you very little
Well, I don't think that the SQL statment are so huge.
I had this problem once:
I have to split my string because I get an error in runtime. So, maybe it is the same error.Code:CString strAux = "SELECT DISTINCT \
GenInfInforme.sINFO_CODIGO, \
GenInfInformeDetalles.sIDET_VISTA, \
GenInfInformeDetalles.sIDET_CONSULTA, \
GenInfInformeDetalles.sIDET_USUARIO, \
GenInfArbolesCF.sGIAR_ARBOL, \
GenInfArbolesCF.nGIAR_COMPORT, \
GenInfArbolesCF.nGIAR_TIPOEJE, \
GenInfArbolesCF.nGIAR_PROFUN, \
GenInfArbolesCF.sGIAR_NODO, \
MasterTreesStructure.NodeCode, \
MasterTrees.TreeNumberOfLevels,\
MasterTreesStructure.NodeLevel, \
MasterTreesStructure.NodeTreeOrder \
FROM GenInfInforme INNER JOIN \
GenInfInformeDetalles ON \
(GenInfInformeDetalles.sINFO_CODIGO = GenInfInforme.sINFO_CODIGO) \
INNER JOIN Users ON (Users.UsuarioID = GenInfInforme.sINFO_USUARIO)\
INNER JOIN \
GenInfArbolesCF ON \
(GenInfInformeDetalles.sIDET_VISTA = GenInfArbolesCF.sGIAR_VISTA \
AND \
GenInfInformeDetalles.sIDET_CONSULTA = GenInfArbolesCF.sGIAR_CONSULTA \
AND \
GenInfInformeDetalles.sIDET_USUARIO = GenInfArbolesCF.sGIAR_USUARIO \
AND \
GenInfInformeDetalles.sINFO_CODIGO = GenInfArbolesCF.sGIAR_CODIGO) \
INNER JOIN \
MasterTrees ON \
(GenInfArbolesCF.sGIAR_ARBOL = MasterTrees.TreeMasterCode) \
INNER JOIN \
MasterTreesStructure ON \
(GenInfArbolesCF.sGIAR_ARBOL = MasterTreesStructure.TreeMasterCode) ";
strAux += "WHERE ((GenInfInforme.bINFO_PRIVADO = 0 AND Users.GrupoID = '%s') OR \
GenInfInforme.sINFO_USUARIO = '%s') AND \
((GenInfArbolesCF.nGIAR_TIPOEJE = 2) OR \
((GenInfArbolesCF.nGIAR_TIPOEJE < 2) AND \
((MasterTrees.TreeNumberOfLevels - 1) \
> MasterTreesStructure.NodeLevel))) AND \
((GenInfArbolesCF.nGIAR_COMPORT = 0) OR \
((GenInfArbolesCF.nGIAR_COMPORT > 0) AND \
((MasterTrees.TreeNumberOfLevels - MasterTreesStructure.NodeLevel \
- 1) >= GenInfArbolesCF.nGIAR_PROFUN))) \
ORDER BY GenInfInforme.sINFO_CODIGO, \
GenInfInformeDetalles.sIDET_VISTA, \
GenInfInformeDetalles.sIDET_CONSULTA, \
GenInfInformeDetalles.sIDET_USUARIO, \
GenInfArbolesCF.sGIAR_ARBOL, \
MasterTreesStructure.NodeLevel, \
MasterTreesStructure.NodeTreeOrder";
I didn't mean that to be related to this guys problem. I mean is that a bug in CStringQuote:
Originally posted by Mick_2002
Speculation :) I'd like to see what is going on first....
thank you very little
What was the runtime error? The char looks proper to meQuote:
Originally posted by irona20
Well, I don't think that the SQL statment are so huge.
I had this problem once:
I have to split my string because I get an error in runtime. So, maybe it is the same error.Code:CString strAux = "SELECT DISTINCT \
GenInfInforme.sINFO_CODIGO, \
GenInfInformeDetalles.sIDET_VISTA, \
GenInfInformeDetalles.sIDET_CONSULTA, \
GenInfInformeDetalles.sIDET_USUARIO, \
GenInfArbolesCF.sGIAR_ARBOL, \
GenInfArbolesCF.nGIAR_COMPORT, \
GenInfArbolesCF.nGIAR_TIPOEJE, \
GenInfArbolesCF.nGIAR_PROFUN, \
GenInfArbolesCF.sGIAR_NODO, \
MasterTreesStructure.NodeCode, \
MasterTrees.TreeNumberOfLevels,\
MasterTreesStructure.NodeLevel, \
MasterTreesStructure.NodeTreeOrder \
FROM GenInfInforme INNER JOIN \
GenInfInformeDetalles ON \
(GenInfInformeDetalles.sINFO_CODIGO = GenInfInforme.sINFO_CODIGO) \
INNER JOIN Users ON (Users.UsuarioID = GenInfInforme.sINFO_USUARIO)\
INNER JOIN \
GenInfArbolesCF ON \
(GenInfInformeDetalles.sIDET_VISTA = GenInfArbolesCF.sGIAR_VISTA \
AND \
GenInfInformeDetalles.sIDET_CONSULTA = GenInfArbolesCF.sGIAR_CONSULTA \
AND \
GenInfInformeDetalles.sIDET_USUARIO = GenInfArbolesCF.sGIAR_USUARIO \
AND \
GenInfInformeDetalles.sINFO_CODIGO = GenInfArbolesCF.sGIAR_CODIGO) \
INNER JOIN \
MasterTrees ON \
(GenInfArbolesCF.sGIAR_ARBOL = MasterTrees.TreeMasterCode) \
INNER JOIN \
MasterTreesStructure ON \
(GenInfArbolesCF.sGIAR_ARBOL = MasterTreesStructure.TreeMasterCode) ";
strAux += "WHERE ((GenInfInforme.bINFO_PRIVADO = 0 AND Users.GrupoID = '%s') OR \
GenInfInforme.sINFO_USUARIO = '%s') AND \
((GenInfArbolesCF.nGIAR_TIPOEJE = 2) OR \
((GenInfArbolesCF.nGIAR_TIPOEJE < 2) AND \
((MasterTrees.TreeNumberOfLevels - 1) \
> MasterTreesStructure.NodeLevel))) AND \
((GenInfArbolesCF.nGIAR_COMPORT = 0) OR \
((GenInfArbolesCF.nGIAR_COMPORT > 0) AND \
((MasterTrees.TreeNumberOfLevels - MasterTreesStructure.NodeLevel \
- 1) >= GenInfArbolesCF.nGIAR_PROFUN))) \
ORDER BY GenInfInforme.sINFO_CODIGO, \
GenInfInformeDetalles.sIDET_VISTA, \
GenInfInformeDetalles.sIDET_CONSULTA, \
GenInfInformeDetalles.sIDET_USUARIO, \
GenInfArbolesCF.sGIAR_ARBOL, \
MasterTreesStructure.NodeLevel, \
MasterTreesStructure.NodeTreeOrder";
I didn't look...should I look? :) Given the number of bugs in MFC I do not doubt it :)Quote:
Originally posted by souldog
I didn't mean that to be related to this guys problem. I mean is that a bug in CString
I don't renember, it was three years ago :) I only renember I had to split my string.Quote:
Originally posted by Mick_2002
What was the runtime error? The char looks proper to me
For wangnanjing
If your problem is really an SQL statement, something like "SELECT blabla,... FROM...",
If you can zip and attach it here, then there is no problem. For sure, somebody will help you.
I have a supposition. Somehow your "SQL" is a long binary field in a recordset,
and you had some problems trying to put it in a CString ???
Heh it's ok Irona...given the number of responses, it will be three years before the original poster responds :)Quote:
Originally posted by irona20
I don't renember, it was three years ago :) I only renember I had to split my string.
Do you know any software stuff without bugs?Quote:
Originally posted by Mick_2002
I didn't look...should I look? :) Given the number of bugs in MFC I do not doubt it :)
Yes? That means it does nothing.
Yep...it's called any code I write...what you never heard of FVT or UNIT testing...wow imagine that....Quote:
Originally posted by ovidiucucu
Do you know any software stuff without bugs?
Yes? That means it does nothing.
EDIT: does it piss me off to no end that you have that attitude? yes it does.
Sorry man, you must throw it away!Quote:
Originally posted by Mick_2002
Yep...it's called any code I write...what you never heard of FVT or UNIT testing...wow imagine that....
Or it's insufficient tested, or nobody use it except you.
Keep in mind: nothing is perfect.
I hope no offense, Just :D :D :DQuote:
Originally posted by Mick_2002
EDIT: does it piss me off to no end that you have that attitude? yes it does.
Wow...geez, I've never coded for the big boys :) Why don't you try your attitude when coding for medical devices? Hmm? Maybe your NIBP isn't what your NIBP is? hmm? Maybe somebody makes a descision based on your cardiac calcs? Maybe then your dead :)Quote:
Originally posted by ovidiucucu
Sorry man, you must throw it away!
Or it's insufficient tested, or nobody use it except you.
Keep in mind: nothing is perfect.
Stupidity is no offense, it's called darwinism :)Quote:
I hope no offense, Just :D :D :D