Click here to Skip to main content
16,004,969 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: help.. Pin
Malli_S17-Dec-08 18:18
Malli_S17-Dec-08 18:18 
AnswerRe: help.. Pin
Jijo.Raj17-Dec-08 21:01
Jijo.Raj17-Dec-08 21:01 
AnswerRe: help.. Pin
aks.17-Dec-08 22:54
aks.17-Dec-08 22:54 
QuestionVisual C++ 6.0 and Visual Studio 2005 Pin
izyani17-Dec-08 14:23
izyani17-Dec-08 14:23 
QuestionVC++ 2008 Command line builder Pin
pratap198017-Dec-08 8:24
pratap198017-Dec-08 8:24 
AnswerRe: VC++ 2008 Command line builder Pin
led mike17-Dec-08 9:17
led mike17-Dec-08 9:17 
AnswerRe: VC++ 2008 Command line builder Pin
Jijo.Raj17-Dec-08 9:42
Jijo.Raj17-Dec-08 9:42 
QuestionUsing CRecordset with foreign keys Pin
mevatron117-Dec-08 8:11
mevatron117-Dec-08 8:11 
Hi,

I'm fairly new to database programming, but I have been using MFC and C++ for a while. So, here is the problem I'm having.

Here is a basic description of the two tables I'm using.
PersonTable
PersonId, INT, AUTO_INCREMENT (Primary Key)
Name, VARCHAR(32)

ImageTable
ImageId, INT, AUTO_INCREMENT (Primary Key)
ImageBlob, LARGE_BLOB
PersonId, INT (Foreign Key)

Basically, I want to insert the person record into the person table, next insert the image for that person into the image table, and finally link the ImageTable.PersonId to the PersonTable.PersonId.

So, here is the code I'm currently using
<br />
personTable.AddNew();<br />
personTable.m_Name = "Joe";<br />
personTable.Update();<br />
<br />
personTable.Requery();<br />
personTable.MoveLast();<br />
<br />
long personId_ForeignKey = personTable.m_PersonId;<br />
<br />
//... later in the image table insert code<br />
imageTable.AddNew();<br />
// set the image blob here<br />
imageTable.m_PersonId = personId_ForeignKey;<br />
imageTable.Update();


This works, but what concerns me is that this isn't safe for concurrent inserts. If multiple clients are inserting into the database, then I could get the wrong foreign key when I call "personTable.MoveLast()." Is there a better way to do this? Thanks!

-Will
AnswerRe: Using CRecordset with foreign keys Pin
led mike17-Dec-08 9:13
led mike17-Dec-08 9:13 
GeneralRe: Using CRecordset with foreign keys Pin
mevatron117-Dec-08 11:16
mevatron117-Dec-08 11:16 
GeneralRe: Using CRecordset with foreign keys Pin
led mike18-Dec-08 6:53
led mike18-Dec-08 6:53 
GeneralRe: Using CRecordset with foreign keys Pin
mevatron118-Dec-08 7:17
mevatron118-Dec-08 7:17 
QuestionRe: Using CRecordset with foreign keys Pin
David Crow17-Dec-08 10:30
David Crow17-Dec-08 10:30 
AnswerRe: Using CRecordset with foreign keys Pin
mevatron117-Dec-08 11:16
mevatron117-Dec-08 11:16 
AnswerRe: Using CRecordset with foreign keys Pin
mevatron117-Dec-08 11:48
mevatron117-Dec-08 11:48 
QuestionAbout USB ports Pin
ameyakoshti17-Dec-08 7:09
ameyakoshti17-Dec-08 7:09 
AnswerRe: About USB ports Pin
Jonathan Davies17-Dec-08 7:33
Jonathan Davies17-Dec-08 7:33 
GeneralRe: About USB ports Pin
ameyakoshti17-Dec-08 8:09
ameyakoshti17-Dec-08 8:09 
GeneralRe: About USB ports Pin
Jonathan Davies18-Dec-08 2:07
Jonathan Davies18-Dec-08 2:07 
GeneralRe: About USB ports Pin
ameyakoshti18-Dec-08 3:20
ameyakoshti18-Dec-08 3:20 
Questionlistview Pin
trioum17-Dec-08 2:06
trioum17-Dec-08 2:06 
AnswerRe: listview Pin
VC++Maniac17-Dec-08 2:14
VC++Maniac17-Dec-08 2:14 
AnswerRe: listview Pin
Jijo.Raj17-Dec-08 2:28
Jijo.Raj17-Dec-08 2:28 
Questioninplace edit of doc title Pin
VC++Maniac17-Dec-08 1:44
VC++Maniac17-Dec-08 1:44 
QuestionRe: inplace edit of doc title Pin
David Crow17-Dec-08 3:11
David Crow17-Dec-08 3:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.