|
Does m_pRecordset->Fields->Item[0L] have a valid value? (You can test it with an ASSERT).
Caveat: I'm ADO ignorant.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
yes its a valid column in the database. Its cousin GetChunk is working happpily on it to retreive data. Now I'm trying to put data into the table. This seemed the most understandable way..
Thanks for the reply. I was wondering where you were!;P
|
|
|
|
|
I'm around...
Been working on a hack[^] for my sister-in-law who (bless her heart!) has EBay-itis, but uses a humble 28.8 modem. Now other people have started using it and have been sending me feature requests. I love it!
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
The link to the hack is invalid.
I'm sort of having fun too....ADO is doable.
|
|
|
|
|
Glad you're having fun, and it's not much ADO about nothing. Sorry, sometimes I think I'm a punny guy. Damn.
The link is fixed. You can see it here[^].
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
A couple of things: 1) A CString can't hold binary data from a bitmap. Bitmaps have NULL characters which CString uses to find the end of the string. Don't use the CString at all, it's not needed.
2). You use pImage with initializing it. char *pImage = new char[ size ]; also don't forget to delete [] pImage;
3). no need to put a zero at the end, NULL terminating binary data really doesn't do or mean anything.
There are other things that are not needed and the code could be greatly simplified but your basic assumptions are a tad off.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
In this line:
memcpy((LPVOID)pByte,(LPVOID)CImage.GetBuffer(CImage.GetLength()),CImage.GetLength()+1);
if my data is stored in pImage, what shall I use inplace of CString CImage?
I have this to fill:
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].cElements = CImage.GetLength() * sizeof(TCHAR) + sizeof(TCHAR)
so I dont know how to perform these operations on a char* instead of a CString. I cant do strlen on the pImage because its got lots of embedded nulls. What to do to get the length of the image char* buffer?
Thanks,
ns
|
|
|
|
|
I made some modifications (didnt use cString) and it never gets into the if to do the memcpy:
if(SafeArrayAccessData(psa,(void **)&pByte) == NOERROR)
memcpy((LPVOID)pByte,(LPVOID)pImage,size+1);
SafeArrayUnaccessData(psa);
The changes I made are:
size = fileSize;
char *pImage;
pImage = new char[size+1];
fread(pImage, size, 1, pFile);
fclose(pFile);
SAFEARRAY FAR* psa;
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = size * sizeof(TCHAR) + sizeof(TCHAR);
psa = SafeArrayCreate(VT_I1, 1, rgsabound);
if(SafeArrayAccessData(psa,(void **)&pByte) == NOERROR)
memcpy((LPVOID)pByte,(LPVOID)pImage,size+1);
SafeArrayUnaccessData(psa);
varArray.vt = VT_ARRAY | VT_UI1;
varArray.parray = psa;
WHat can I do to get to the memcpy statement?
Thanks,
ns
|
|
|
|
|
Ok, let's try a different tact:
void BlobToVariant( COleVariant &varArray )
{
CFile file;
COleSafeArray safeArray;
void *data;
if (!file.Open( "c:\\windows\\rhododendron.bmp", CFile::modeRead ))
{
return;
}
safeArray.CreateOneDim( VT_UI1, file.GetLength() );
safeArray.AccessData( (void*)&data );
file.Read( data, file.GetLength() );
file.Close();
safeArray.UnaccessData();
varArray = safeArray;
}
void DbClass::AddNewRecord( char *key1, char *value1 )
{
COleVariant varArray;
BlobToVariant( varArray );
m_pRecordset->AddNew();
m_pRecordset->Fields->Item[ 0L ]->AppendChunk( varArray );
m_pRecordset->Update();
m_pRecordset->MoveLast();
}
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
It didnt crash. It told me that the recordcount was increasing. But when i looked in the db, no new entries! Aaargh!
My recordset is opened as:
m_pRecordset->CursorLocation = adUseClient;
m_pRecordset->Open ((IDispatch *) m_pCommand, vtMissing, adOpenStatic,
adLockBatchOptimistic, adCmdText);
I really do appreciate your efforts. Thanks very much,
ns
|
|
|
|
|
I've got an array class with 2 GetAt members:
__forceinline CString CFStrArray::GetAt(int nIndex) const
{
CString str =
return str;
}
__forceinline void CFStrArray::GetAt(int nIndex, LPSTR sz) const
{
CString str = GetAt(nIndex);
sz = str.GetBuffer(1);
str.ReleaseBuffer();
} The first works fine, but the second one fails to return the value in the LPSTR. I need to have both the CString return version and an LPSTR return version, how can I achieve this?
Dylan Kenneally
London, UK
|
|
|
|
|
Dylan,
The GetBuffer() member function of the CString class returns the pointer to the actual character data used by the class. This can be used to directly modify the CString object data (though I think this is very dangerous).
This means the the moment you call ReleaseBuffer(), the address returned may very well be invalid.
try:
CString str = GetAt(nIndex);
LPTSTR czBuffer = str.GetBuffer(1);
strcpy(sz, czBuffer);
str.ReleaseBuffer();
Richard Chin
|
|
|
|
|
Why do you need 'char *' (LPSTR)? 'const char *' wouldn't be appropriate?
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Dylan Kenneally wrote:
__forceinline void CFStrArray::GetAt(int nIndex, LPSTR sz) const{ CString str = GetAt(nIndex); sz = str.GetBuffer(1); str.ReleaseBuffer();}
This releases the buffer before you return it
you should use something like
__forceinline void CFStrArray::GetAt(int nIndex, LPSTR sz,int nCount) const<br />
{<br />
CString str = GetAt(nIndex);<br />
if (str.GetLength() < nCount)<br />
strcpy(sz,str);<br />
else<br />
{<br />
strncpy(sz,str,nCount-1);<br />
sz[nCount-1]="\0";<br />
}<br />
}
Ofcource it is now the responsibility of the calling function to reserve space for sz
|
|
|
|
|
Hi all,
which is the best place to learn about "Sound card Audio Mixers"
thankQ
|
|
|
|
|
I don't know about the best place, but you could try right here at CP[^] for starters.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
hi all,
i want to know any character can trigger return of recv() function?
i used java to send data to VC++ client. for example, i send 5 lines to VC client and i want to have 5 times of return in recv().
what can i do?
example:
while(y=recv(pSoc->conn,buff,512,0))
{
// i want to run 5 times of this loop.
// for 5 lines of data
// e.g.
// loginlist
// Jim
// Mary
// Joe
// Ken
// 5 lines of data, want to have 5 returns in recv(), any help?
}
thanks,
jim
|
|
|
|
|
That's not how sockets work. You may get all lines in one recv() response, or one character per recv() , and your code must be able to deal with it.
|
|
|
|
|
thanks!
so, do you know how can i control when the recv() return? or, it is in random manner?
pls give me some idea!
jim
|
|
|
|
|
Hi,
I have very big Visual C++ project I undertook after the other programmer. Now, I found out irregular fatal errors. Windows write something like "....instruction on address blahblah....memory cant be written...". I really cant go through source code and find possible problems because it is really big project. So how can I fix it ?? I say again, this error is very irregular and sometimes, the program finishes its work perfectly...I am very confused. Is there any way to find the error ? I have VC++ 6.0.
Thanks in advance, any suggestion will be appreciated !
Celebrate Mr. Cesilko!
|
|
|
|
|
You'll need some automated error detection tool, like BoundsChecker or Purify. The problem smells like heap corruption or writing past the end of array.
s_k wrote:
sometimes, the program finishes its work perfectly
Forget about it. Treat your app as a 2-engine plane with first engine totally broken. Second may fail any moment now leading to disaster.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Thanks for your reply!
But, where can I get BoundsChecker, trial version, because I havent got money enough to buy commercial version...?
Celebrate Mr. Cesilko!
|
|
|
|
|
in VB theres the app path that you can tack on before the filename. How can you automatically detect your location in VC?
Thanksd,
ns
|
|
|
|