1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Composite Primary Key - How to increment one, while keeping the other constant?

Discussion in 'C#' started by thedunnyman, May 22, 2008.

  1. #1
    Hey guys,

    Just trying to design a table which as one key that signifies a document. And the other key signifies the sections in the document. But the overall document can change as well.

    I.e.

    DOCUMENT 1 - Section 1/2/3/4
    DOCUMENT 2 - Section 1/2
    DOCUMENT 3 - Section 1
    DOCUMENT 4 - Section 1/2/3/4

    So basically, the section IDs should start again.

    Here is the table i'm making with in MySQL:
    SEMrush

    And then in my ASP pages, I tried to do this:

    But I get this error when the page runs:


    So is there a way to get something implemented this way?
    Sorry I am new at SQL/ASP so anything would be helpful!

    Thanks,
    Duncan :)
     
    thedunnyman, May 22, 2008 IP
    SEMrush
  2. ashbeats

    ashbeats Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You have declared the fields as NOT NULL, making it compulsory for it to be assigned a value. Why don't
    you just use '0' instead of null when inserting
     
    ashbeats, May 22, 2008 IP
  3. thedunnyman

    thedunnyman Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply.

    With 0 it works, but I need this to restart counting back at one. (as required by the specifications of this project).

    So for every new document, I'll need the section ID to start back at 1 again.

    Is this possible?
     
    thedunnyman, May 22, 2008 IP