473,698 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Upda te() 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.t xt";
CFile f;
CByteArray ByteArray;

if (f.Open(FileNam e, CFile::modeRead , &e ))
{
CByteArray ByteArray;
long size = f.GetLength();
ByteArray.SetSi ze(size);
BYTE *p = ByteArray.GetDa ta();
ZeroMemory(p, size);
long result = f.Read(p, size);

table.AddNew();

if(!(table.m_da ta.m_hData))
{
::GlobalFree(ta ble.m_data.m_hD ata);
table.m_data.m_ hData = GlobalAlloc(GME M_MOVEABLE,size );
if(table.m_data .m_hData) // GlobalAlloc could return NULL...
{
table.m_data.m_ dwDataLength = size;
LPVOID p2 = ::GlobalLock(ta ble.m_data.m_hD ata);
memcpy(p2, p, size);
::GlobalUnlock( table.m_data.m_ hData);
table.m_data.m_ dwDataLength = ::GlobalSize(ta ble.m_data.m_hD ata);

// mark the record for the update
table.SetFieldD irty(&(table.m_ data), true);
table.SetFieldN ull(&(table.m_d ata), false);
}
else
{
AfxMessageBox(" Couldn't allocate memory");
}
}

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

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

Similar topics

2
2519
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) char lpResourceID; rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, &lpResourceID, RESOURCE_ID_LEN_PLUS_NULL , &nLen1); and this works fine , however trying to move codebase to UNICODE an
7
3533
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 necessary changes on the functions and recreated all my types and functions. It seemd to be all right, but the newly created functions won't work anymore.
2
2056
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 changed to update the existing record instead? -- Eugene Vital Any technology indistinguishable from magic is insufficiently advanced.
9
3049
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 the form. After the requery the records are in different order to the order that they may be entered in. The record does not seem to be assigned an ID (autonumber ID field) until after it is requeried. My problem is that after requerying the...
13
7284
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
1858
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 written back, but is not being written back to the database. Although I've used a foreach loop there is actually only 1 record in the dataset. I'm going to eventually use transactions but have commented them out for now
0
1039
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 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
0
1647
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, but I have to support all modern Windows systems, and a variety of ODBC configurations. (I'll be testing against multiple ODBC databases soon - but development is against MySQL) I've been able to adapt some example code that executes a...
33
3331
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 of 20 steps) On the admin page the steps are listed, in "order" order and the user can create new steps and assign an order and all is well. The problem may come in using a renumber function which should take the steps in their current order...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.