Re: MFC/ODBC/ACCESS Creating a New DataRecord in a table with primary key
From: Tim (Tim_at_NoSpam)
Date: 07/13/04
- Next message: Danny Ni: "newbie needs clarification about Standard C++ libray"
- Previous message: Andre: "Re: calculate polynomial in MFC"
- In reply to: Richard Rauch: "MFC/ODBC/ACCESS Creating a New DataRecord in a table with primary key"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 13 Jul 2004 13:19:58 +1200
Richard,
You need to look at the design of the table to get the answer.
The error message is quite informative - it is telling you that you have
violated a constraint - in this case either an index, primary key, or
relationsip.
>From what you have said, I would look first at the Identity column - you
cannot specify a value to go into an identity column under normal
circumstances.
- Tim
"Richard Rauch" <Richard.Rauch@vipa.de> wrote in message
news:eLNmxoAaEHA.3112@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I want to create a small MFC Programm for accessing a Microsoft Access
> Database.
> I have a table with an auto number field as primary key. From my
> MFC-Application i want to insert a new record. Doing this, i will get the
> following error message:
> "
> Error: failure updating record.
> The changes you requested to the table were not successful because they
> would cr
> eate duplicate values in the index, primary key, or relationship. Change
> the da
> ta in the field or fields that contain duplicate data, remove the index,
> or
> rede
> fine the index to permit duplicate entries and try again.
> State:23000,Native:-1605,Origin:[Microsoft][ODBC Microsoft Access Driver]
> "
> Im principle, I'm working with an example from the book "Inside Visual
> C++"
> The Source Code for Creating a new record:
>
> void CDevDBClientView::OnRecordAdd()
> {
> m_pSet->AddNew();
> UpdateData(TRUE);
> if ( m_pSet->CanUpdate() )
> {
> m_pSet->Update();
> }
> if ( !m_pSet->IsEOF() )
> {
> m_pSet->MoveLast();
> }
> UpdateData(FALSE);
> }
>
> Is there any possibility to get the new key from the database instead of
> creating an unique key from the program itself?
>
> Thanks
>
> Richard
>
>
- Next message: Danny Ni: "newbie needs clarification about Standard C++ libray"
- Previous message: Andre: "Re: calculate polynomial in MFC"
- In reply to: Richard Rauch: "MFC/ODBC/ACCESS Creating a New DataRecord in a table with primary key"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|