Click here to Skip to main content
15,886,519 members
Home / Discussions / Database
   

Database

 
Generalselect year/month syntax (for contracts up for renewal in X month) Pin
tellytub18-Dec-07 16:09
tellytub18-Dec-07 16:09 
GeneralRe: select year/month syntax (for contracts up for renewal in X month) Pin
Giri K18-Dec-07 17:11
Giri K18-Dec-07 17:11 
GeneralRe: select year/month syntax (for contracts up for renewal in X month) Pin
tellytub18-Dec-07 20:15
tellytub18-Dec-07 20:15 
GeneralRe: select year/month syntax (for contracts up for renewal in X month) Pin
Giri K19-Dec-07 11:55
Giri K19-Dec-07 11:55 
Questionjoins of two tables +search Pin
regin18-Dec-07 1:42
regin18-Dec-07 1:42 
GeneralRe: joins of two tables +search Pin
pmarfleet18-Dec-07 1:59
pmarfleet18-Dec-07 1:59 
GeneralRe: joins of two tables +search Pin
andyharman18-Dec-07 3:47
professionalandyharman18-Dec-07 3:47 
QuestionHow to get generated Primary Key when adding a record Pin
gunner_uk200018-Dec-07 1:35
gunner_uk200018-Dec-07 1:35 
I have these (amongst others) tables in my database:

Tasks and Successors

Tasks hold details about task, and Successors has two taskIDs as forgien keys (jointly primary key) to hold data on the relationship between task.

Ie Task A has Tasks B and C as successors.

Task Table has three records for the task. The Successor table has TaskA/B and TaskA/C primary key feilds.

I'm using this on a C# Clone of MS Project. So I'm reading this data in and converting them into classes, in a tree structure so each Task Object has a List<task> of successors.

I can read this data in fine by just parsing the data in the tables. The problem comes when I want to put newly created data into the database, which is stored in this tree of instances of Task.

[b]If I put add a Task record into the database, how do I get the primary key of the one I've just put in so that I can create the records in the successor table to link them?[/b]

In my example I will probably have to added the tasks 1st so that when I add the successor records, the tasks actually exists. The algorithim for this will be quite simple if I was able to get the primary keys when I adding the tasks.

Anyone have any idea on how to do this?

Thanks for any help,

Ian.
AnswerRe: How to get generated Primary Key when adding a record Pin
Pete O'Hanlon18-Dec-07 1:38
mvePete O'Hanlon18-Dec-07 1:38 
AnswerRe: How to get generated Primary Key when adding a record Pin
Giorgi Dalakishvili18-Dec-07 1:42
mentorGiorgi Dalakishvili18-Dec-07 1:42 
Questionselect the max value from the row and its other values Pin
Deques18-Dec-07 1:19
Deques18-Dec-07 1:19 
GeneralRe: select the max value from the row and its other values Pin
Tobias Schoenig18-Dec-07 1:41
Tobias Schoenig18-Dec-07 1:41 
GeneralRe: select the max value from the row and its other values Pin
Deques18-Dec-07 1:51
Deques18-Dec-07 1:51 
GeneralRe: select the max value from the row and its other values Pin
Tobias Schoenig18-Dec-07 1:59
Tobias Schoenig18-Dec-07 1:59 
GeneralRe: select the max value from the row and its other values Pin
Deques18-Dec-07 2:05
Deques18-Dec-07 2:05 
GeneralRe: select the max value from the row and its other values Pin
Tobias Schoenig18-Dec-07 2:10
Tobias Schoenig18-Dec-07 2:10 
GeneralRe: select the max value from the row and its other values Pin
Deques18-Dec-07 2:17
Deques18-Dec-07 2:17 
GeneralRe: select the max value from the row and its other values Pin
Tobias Schoenig18-Dec-07 2:22
Tobias Schoenig18-Dec-07 2:22 
GeneralRe: select the max value from the row and its other values Pin
Deques18-Dec-07 2:31
Deques18-Dec-07 2:31 
GeneralRe: select the max value from the row and its other values Pin
Tobias Schoenig18-Dec-07 2:32
Tobias Schoenig18-Dec-07 2:32 
GeneralRe: select the max value from the row and its other values Pin
Deques18-Dec-07 2:43
Deques18-Dec-07 2:43 
GeneralRe: select the max value from the row and its other values Pin
Tobias Schoenig18-Dec-07 2:49
Tobias Schoenig18-Dec-07 2:49 
GeneralRe: select the max value from the row and its other values Pin
Deques18-Dec-07 2:53
Deques18-Dec-07 2:53 
GeneralRe: select the max value from the row and its other values Pin
Rupert Todd19-Dec-07 9:36
Rupert Todd19-Dec-07 9:36 
Generalcalling a storedprocedure from a function in mysql Pin
sepel18-Dec-07 0:35
sepel18-Dec-07 0:35 

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.