473,385 Members | 1,766 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,385 software developers and data experts.

stymied by ADO

i have a vc++ gui interface to an MSAccess table. Everything works fine -
i can navigate (first, prev, next, last) and save, insert and delete records.

now the problem occurs: i changed the attributes of the MSAccess table
so now there is a primary key that can not be null and attempts to
add a new record fail/throw exception with complaints about trying to add a record with a null value.

the table of postal rates has the follwoing fields:

Use
RateDate
InitialRate
InitialWeight
InrementalRate
IncrementalWeight

with RateDate having been elevated to primary key status.

the code to transfer data from the dialog to the table is as follows (with
a note where the exception occurs):


AccessDBManager.vName = "Use";
if ( ((CButton*)GetDlgItem(IDC_CHK_USE))->GetCheck() == 0 ){
AccessDBManager.vValue = "0";
}
else{
AccessDBManager.vValue = "-1";
}
AccessDBManager.RecordsetPtr->Update( // exception thrown here!
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "RateDate";
GetDlgItem(IDC_EDT_RATEDATE)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "RateInit";
GetDlgItem(IDC_EDT_RATEINIT)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "WeightInit";
GetDlgItem(IDC_EDT_WEIGHTINIT)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "RateIncr";
GetDlgItem(IDC_EDT_RATEINCR)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "WeightIncr";
GetDlgItem(IDC_EDT_WEIGHTINCR)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

the problem seems to me that upon trying to update the "Use" field MSAcess
now notes that the "RateDate" field is empty. Changing the order of
the updates is not an acceptable solution since there can be more than one
primary key, in general, and the problem would still occur.

what is the trick to accomplish this?

thanks in advance.
Mar 1 '07 #1
2 1803
sicarie
4,677 Expert Mod 4TB
i have a vc++ gui interface to an MSAccess table. Everything works fine -
i can navigate (first, prev, next, last) and save, insert and delete records.

now the problem occurs: i changed the attributes of the MSAccess table
so now there is a primary key that can not be null and attempts to
add a new record fail/throw exception with complaints about trying to add a record with a null value.

the table of postal rates has the follwoing fields:

Use
RateDate
InitialRate
InitialWeight
InrementalRate
IncrementalWeight

with RateDate having been elevated to primary key status.

the code to transfer data from the dialog to the table is as follows (with
a note where the exception occurs):


AccessDBManager.vName = "Use";
if ( ((CButton*)GetDlgItem(IDC_CHK_USE))->GetCheck() == 0 ){
AccessDBManager.vValue = "0";
}
else{
AccessDBManager.vValue = "-1";
}
AccessDBManager.RecordsetPtr->Update( // exception thrown here!
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "RateDate";
GetDlgItem(IDC_EDT_RATEDATE)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "RateInit";
GetDlgItem(IDC_EDT_RATEINIT)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "WeightInit";
GetDlgItem(IDC_EDT_WEIGHTINIT)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "RateIncr";
GetDlgItem(IDC_EDT_RATEINCR)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

AccessDBManager.vName = "WeightIncr";
GetDlgItem(IDC_EDT_WEIGHTINCR)->GetWindowText( s );
AccessDBManager.vValue = s;
AccessDBManager.RecordsetPtr->Update(
AccessDBManager.vName,
AccessDBManager.vValue
);

the problem seems to me that upon trying to update the "Use" field MSAcess
now notes that the "RateDate" field is empty. Changing the order of
the updates is not an acceptable solution since there can be more than one
primary key, in general, and the problem would still occur.

what is the trick to accomplish this?

thanks in advance.
::bumping the thread in hope of getting someone's attention who has worked with Access and C++ before::
Mar 5 '07 #2
willakawill
1,646 1GB
Would you please explain in a little more detail why you can't update RateDate before you update Use?
Mar 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MemphisWeb | last post by:
I have a pdf govt issue tax form for non-profits and am trying to write a script that will handle browser based entry of data fields as well as save some info to database It is a tax form and...
2
by: John Murtari | last post by:
Folks, We are slow in rolling out PHP 5 to our users because it won't live as a module with PHP 4 in Apache 1.3.x/Linux. I have seen many workaround like running it as CGI or using a reverse...
1
by: Neil MacGaffey | last post by:
Hi - I'm new to python and am stymied by something that should be simple. The file open command below works fine on my desktop machine, but I cant get it to work on my laptop. Since using...
2
by: uh6uj | last post by:
I have a rather general question regarding choice of language. I stumbled on ASP.NET a little while ago when I first started learnin JavaScript. I thought .NET was great and have started to learn...
0
by: Charles Blaquière | last post by:
While noodling around, looking for a good layout for an "events calendar" page, I came upon a problem that has me stymied. Have a look at http://kpuc.org/events/upcoming-2.html . The basic...
0
by: Michael Andersson | last post by:
Given a set of classes class A { enum [ ID = 0x0001} }; class B { enum [ ID = 0x0002} }; class B { enum [ ID = 0x0004} }; I wish to generate a composite class, perhaps using something like...
3
by: Lionel B | last post by:
In an overloaded output operator for a class I want to detect ostream manipulators such as flush, endl, ends, etc. I am stymied by how to do this; here's a minimal program indicating my problem: ...
1
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I posted this about a month ago but didn't get any response, so I thought I'd rephrase it. I have a DateTimePicker set for Up/Down Time format (HH:mm:ss). The problem is that when I...
1
by: Casey Rodarmor | last post by:
Hi All, I'm trying to use a class as a decorator for another class method, but it's giving me a lot of grief. Basically, my problem is with the example below: .... def __init__(self,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.