473,322 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem updating a large binary field (PostgreSQL, ODBC, VC++)

Hello,

I created a table where a record consists of a single field of type
lo. I'm trying to add a new record and store the contents of a file in
it. However, when I call CRecordset.Update() I get the following
exception: "SetPos with data_at_exec not yet supported". My table
doesn't get updated.

Environment: PostgreSQL 7.4.1 on Cygwin, Visual C++ .Net 2003, ODBC
driver 3.520. I pasted my code below (the line that causes the error
is marked). Anyone knows why it doesn't work, and if there's any other
way to do what I want?

TIA,
Pavel

CDatabase db;
CMyTable table(&db);
table.Open();
char* FileName = "c:\\test.txt";
CFile f;
CByteArray ByteArray;

if (f.Open(FileName, CFile::modeRead, &e ))
{
CByteArray ByteArray;
long size = f.GetLength();
ByteArray.SetSize(size);
BYTE *p = ByteArray.GetData();
ZeroMemory(p, size);
long result = f.Read(p, size);

table.AddNew();

if(!(table.m_data.m_hData))
{
::GlobalFree(table.m_data.m_hData);
table.m_data.m_hData = GlobalAlloc(GMEM_MOVEABLE,size);
if(table.m_data.m_hData) // GlobalAlloc could return NULL...
{
table.m_data.m_dwDataLength = size;
LPVOID p2 = ::GlobalLock(table.m_data.m_hData);
memcpy(p2, p, size);
::GlobalUnlock(table.m_data.m_hData);
table.m_data.m_dwDataLength = ::GlobalSize(table.m_data.m_hData);

// mark the record for the update
table.SetFieldDirty(&(table.m_data), true);
table.SetFieldNull(&(table.m_data), false);
}
else
{
AfxMessageBox("Couldn't allocate memory");
}
}

table.Update(); // <-- THIS DOESN'T WORK!
Nov 23 '05 #1
0 1013

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John H | last post by:
Hi , Have a Visual C++ app that use odbc to access sql server database. Doing a select to get value of binary field and bind a char to that field as follows , field in database in binary(16) ...
7
by: Együd Csaba | last post by:
Hi, I've a problem with some of my stored procs. My config is: RH7.1, Postgres 7.3.2 I had converted a few fields of a few tables from one type to another and after this I made all the...
2
by: Gene Vital | last post by:
Hi all. I am using Visual FoxPro via ODBC to update records on a 7.3.4 PostgreSql server and it appears that it always uses delete/insert instead of updating the current record. Can this be...
9
by: Paradigm | last post by:
I am using an Access2K front end to a MYSQL database. If I enter a new record in a continuous form the record appears as #deleted as soon as I move to a different record in the form until I requery...
13
by: Zlatko Matiæ | last post by:
Is it possible to use Access as front-end for POstgreSQL and how ? What about Access Projects (.adp) and PostgreSQL ?
7
by: Zachary Hilbun | last post by:
The below is some test code to help me learn how to update a dataset. It is supposed to read the value of UserCounter and write it back. The UserCounter is being read correctly as 0, is 1 when...
0
by: Pavel Sorokin | last post by:
Hello, I created a table where a record consists of a single field of type lo. I'm trying to add a new record and store the contents of a file in it. However, when I call CRecordset.Update() I...
0
by: Richard Marsden | last post by:
I'm having a lot of trouble writing large chunks of binary data (tests are in the range of 16-512K, but we need support for large longblobs) to MySQL using ODBC. Database is local on a W2K system,...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.