 |
|
 |
I using c++ to make CGI and want to create and store images from and to a database.
My code to do other communication yuo can see below, to retrieve a textfield is ok but I can not find out how to create a image see "???"
CString path="E:\\program files\\Cplusplus\\test\\";
CString searchstr="SELECT * FROM T_Attachments WHERE C_PrimaryKey='" + sKey + "'";
CoInitialize(NULL);
_RecordsetPtr pRs = NULL; //-- This is the Recordset Variable
_ConnectionPtr pCn = NULL; //-- This is the Connection Variable
_bstr_t strCnn("DSN=SupportDSN; UID=xx; PWD=xx");
pCn.CreateInstance(__uuidof(Connection));
pCn->Open(strCnn,"xx","xx",adConnectUnspecified);
pRs.CreateInstance(__uuidof(Recordset));
pRs->Open((LPCTSTR)searchstr,
_variant_t((IDispatch *)pCn,true), adOpenKeyset,
adLockOptimistic, adCmdText);
path+=(char*) ((_bstr_t) pRs->GetFields()->GetItem("C_Name")->GetValue());
CFile outFile(path,CFile::modeCreate|CFile::modeWrite);
buffer = ???
outFile.WriteHuge(buffer,sizeof(buffer));
outFile.Close();
|
|
|
|
 |
|
 |
I am trying to allow the insert/retrieval of BLOBS to my ASA database. When there are no records in the database I am able to add one record. When I try to open the table with any data in the table I get an MFC out of memory error. Has anyone seen this, or have any insight to the problem.
Thanks
Stan
|
|
|
|
 |
|
 |
This may be 3 years late or so, but maybe it'll help someone:
I use Sybase ASA & I've seen this too... I think it has to do w/ the ODBC API call that tells MFC the size of the field after the SELECT statement is executed & before the SQLFetch()/SQLGetData call is made. I think it's SQLDescribeCol... for LONG VARCHAR & LONG BINARY fields, Sybase reports a really huge number, something like what -1 looks like when you view it as an unsigned long. That's not exactly the #, but that's why it gives the 'Out of Memory' exception when it tries to allocate enough memory for the column.
My fix for my LONG VARCHAR fields was to use a CString instead of a CLongBinary, then in CMyRecordset::DoFieldExchange, change the RFX_Text call like so:
RFX_Text(pFX, _T("[myBlob]"), m_strBlob, 4096 * 4, SQL_LONGVARCHAR);
It's not the best to pass a hard coded max buffer size, but it worked for me.
I think you can change that to a variable or function result, but it probably only works if you aren't doing bulk fetching w/ your recordset.
Still working on what to do w/ LONG BINARY tho....
|
|
|
|
 |
|
 |
ok for the creation (addnew) of a BLOB. It work perfectly and my database is just growing up as long as I test it. So how to delete a record. The classical Delete() function gives back error message (I do not previously set the Addnew() or Edit() function as it is requested for the Delete mode). The Update() function gives back the same error (with the Recordset previously set to Edit() mode ).
Thank you very much
Mate
|
|
|
|
 |
|
 |
You need to give a lot more detail to get help from anyone. There are a lot of error messages that you have left us to guess about.
|
|
|
|
 |
|
 |
ok for the creation (addnew) of a BLOB. It work perfectly and my database is just growing up as long as I test it. So how to delete a record. The classical Delete() function gives back error message (I do not previously set the Addnew() or Edit() function as it is requested for the Delete mode). The Update() function gives back the same error (with the Recordset previously set to Edit() mode ).
|
|
|
|
 |
|
 |
I've been using OCI library calls till recently to talk
to ORACLE D/B and it works pretty fine. But when i try
to use ODBC for the same, i am not sure as how the
BLOB object needs to be updated to the D/B. I've tried
it as mentioned in this article, but encounter the error
MissingExpression: ora-00936.
Also when we use OCI calls, we select the OCILobLocator for
update, write into it and just commit. But in the ODBC
version, when i used the edit/update, i observed that
the ultimate SQL statement that is being framed is an
"update".
If anyone has done the BLOB updation to ORACLE using
ODBC, please do let me know as how it needs to be done.
|
|
|
|
 |
|
 |
It strongly depends on the ODBC-Driver Version you're using. i.e. using the latest driver 8.1.77 to read/write a long raw into a 8.1.7 Oracle database with this sample will work, also if you are using the Merant (ex-Intersolv) drivers.
Using older Oracle drivers often leads into the problems you encountered.
|
|
|
|
 |
|
 |
because I already have a m_pMsg in the heap which is allocate by new operator,
I will directly make the m_hData point to my desired content.Using such method,GlobalAlloc()and such like that are thrown off.
But my surprise is that Why must use SetFieldDirty() and SetFieldNull()???
(pCurveIniDataSet->m_data).m_dwDataLength=m_lDataCount*2;
(pCurveIniDataSet->m_data).m_hData=(HGLOBAL)(m_pMsg+240);
pCurveIniDataSet->SetFieldDirty(&(pCurveIniDataSet->m_data));
pCurveIniDataSet->SetFieldNull(&(pCurveIniDataSet->m_data),FALSE);
pCurveIniDataSet->Update();
(pCurveIniDataSet->m_data).m_hData=NULL;
seaguard
|
|
|
|
 |
|
 |
Hi!
When I open Recordset, I have this Exception. Why?
Alexander Sirotkin.
|
|
|
|
 |
|
 |
Hi,
Can you tell me, how can i make Long Binary field in Access 2000 Editor?
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
 |
|
 |
I have the same problem. Did you ever figure this out? Can you just use Memo fields?
|
|
|
|
 |
|
 |
Good Evening,
Just wondering if I'm missing something...
The MSDN docs say that if you use the GMEM_FIXED flag the GlobalUnlock has no effect on memory objects. The GPTR is composed of the GMEM_FIXED flag. So why use the GlobalUnlock function. In the above situation. It seems I'm missing something.
Thanks for any replies!
Scott!
|
|
|
|
 |
|
 |
Good Morning,
I have been working a blob problem all weekend. I just couldn't get things to work right.
Thanks to your time invested in posting this article, it works.
I did not download the file, but the code snippet helped immensely.
Thank You!
Scott!
|
|
|
|
 |
|
 |
This works nicely, after I created an Access 97 .mdb file. It wouldn't work with the one supplied.
I'd like to ask if there is any reason why it creates temporary files for each bitmap displayed? I would prefer
not to create temprorary files, if possible. What I want to do is display an image from the database in a form view. I cannot see how to draw the
bitmap into the dialog or a control (bitmap button or something) without writing it out to a file. If the
image is in CLongBinary variable, how do I get it into a bitmap and then into the control?
Thanks,
Steve
|
|
|
|
 |
|
 |
Good Morning,
If it is appropriate for me to respond...
I don't think it is necessary. In my application I simply instantiate a char * that points to the HGlobal. char * cpMemFile = (char*)GlobalLock( derivedRecordSet->m_hData );
Then use the file.
Scott!
|
|
|
|
 |
|
 |
I bind a LONG column in Oracle with CLongBinary. I followed the same logic described by Sekhar. But I got a error saying "ORA-03127: No operation allowed until the active operation ends". Can anyone tell how i can bind a LONG column with CLongBinary? Thanks
|
|
|
|
 |
|
 |
I also meet this question , I can't write the data in oracle blob field. But I can write in longraw fiel
|
|
|
|
 |
|
 |
I wanna store BLOB data in database. I'm using Visual C++ and Oracle. I'll be really grateful, if u could send me some piece of code.
Thanx in Advanc
|
|
|
|
 |
|
 |
I have the same problem as Hassan Zia.
|
|
|
|
 |
|
 |
Updating oracle CLOBs and BLOBs present numerous problems when using OLEDB, or ADO, however,
are almost trivial if you use the oo4o class library (c++) - oracle puts out a few examples with the
library that are somewhat useful and informative enough to get you started.
|
|
|
|
 |
|
 |
Hello.
I'm trying to write into a BLOB column of a Oracle Table. I'd tried with ODBC Recordset directly but I can't open the recordset with snapshot option... How can I open this recordset to update this column?
Thanks!
C Ortega
|
|
|
|
 |
|
 |
Binding CLongBinary with LONG RAW worked fine for my app.
|
|
|
|
 |
|
 |
The oracle datatype long is just a long string, not binary
data. If this is what your doing just bind the column
to a CString and with RFX_TEXT.
|
|
|
|
 |
|
 |
First I tried to insert a bitmap into my database without MFC. The data is in the colums available, but Access does not recognize it as a bitmap. Access writes "Binary Long-Data" into my column. After that i tried this source and the result is a "Bitmap" column. (As ist should be !). After modifiying the source for my needs access still shows "Binary Long-Data" How to i tell Access, that the data i write to the column is of type "Bitmap" ??? thanx,
|
|
|
|
 |