Problems with MFC AddNew
am 23.01.2007 18:18:48 von Ian KlassenHello,
I'm having some difficulty with adding new records using the ODBC driver
with MFC. This is only occurring is certain situations...
I created a simple table:
CREATE TABLE project (project_id INT PRIMARY KEY);
Using Visual Studio C++ I created a CRecordset class (CProject) to
exchange data with the project table. I then execute the following code:
CDatabase database;
database.OpenEx(_T("DSN=3DPostgreSQL30"));
CProject project(&database);
project.Open();
project.AddNew();
project.m_project_id =3D 1;
project.Update();
I get an Access Violation on the Update(). The log file shows the
following error:
psqlodbc_3100.log:
conn=3D01104290, query=3D'SELECT "project_id" , "ctid", "project_id" FRO=
M
"public"."project"'
[ fetched 0 rows ]
mylog_3100.log:
[1800-4.186]extend_putdata_info: entering ... self=3D016C5EC4,
parameters_allocated=3D0, num_params=3D1
[1800-4.191]extend_putdata_info: unable to create 1 new pdata from 0 old
pdata
Now I've been able to get the Update() to work in the following situation=
s:
- remove the primary key:
CREATE TABLE project (project_id INT);
- change the int to bigint:
CREATE TABLE project (project_id BIGINT PRIMARY KEY);
- make sure at least one record exists in the table:
CREATE TABLE project (project_id INT PRIMARY KEY);
INSERT INTO project (project_id) VALUES (2);
So what's going on? I would like to use int, but if I have to I can
switch to bigint. Thanks for your help.
Ian
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly