how to have sql server generating primary keys oninsertion of record set

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default how to have sql server generating primary keys oninsertion of record set

    Hi everyone,

    I need some help here. I am building a website for a company, which requires
    customerregistration, buying products and so on. My question now is the
    following:

    I have created all the databases I need on my SQL Server 2005 and have
    connected coldfusion to it successfully. I can read in records via the
    coldfusion insert record wizard. But I was hoping sql server to assign my
    primary keys automatically since i have put them on Identity and configured the
    seeds and so on. But everytime i try to read in the records on the site it
    tells me my primary keys cant be null. So does coldfusion now have to assign
    the keys or can I have sql server create them (which i would prefer) somehow.

    Id be real glad for some feedback

    Thanks
    Jay

    surfinjay Guest

  2. Similar Questions and Discussions

    1. Autoincremented id with two primary keys
      Hi all. I have this table: CREATE TABLE sites_pages ( id int(6) NOT NULL, site_id int(4) NOT NULL, name varchar(80) NOT NULL, UNIQUE KEY...
    2. Preserving Primary Keys in DTS
      I have a dev and production server. I want to copy the data from a table in production to DEV and preserve the primary key values. What's the best...
    3. Tablespaces and primary keys
      Implicit indexes created by a constraint do not appear to honor the default tablespace. The index gets created in the "null" tablespace. I took...
    4. Deleting Primary Keys
      Can describe how to drop a primary key from a table? Thanks, Don Bryant
    5. Primary Keys
      How is it that even though I have the column "username" in my database set as a Primary key, using my PHP script to add new users to the database...
  3. #2

    Default Re: how to have sql server generating primary keys oninsertion of record set

    Make the field an identity column

    [url]http://sqlservercode.blogspot.com/[/url]

    SQLMenace Guest

  4. #3

    Default Re: how to have sql server generating primary keys oninsertion of record set

    well as i said all my primary keys in sql server ARE set to integers, identity
    true,seed 1 and increment 1.
    yet if i try to read in data, of course im not reading in the keys. it tells
    me:

    Error Executing Database Query.
    [Macromedia][SQLServer JDBC Driver][SQLServer]DEFAULT or NULL are not allowed
    as explicit identity values.

    So therefore i suppose that sql server did not give them values when i thought
    it was supposed to.

    surfinjay Guest

  5. #4

    Default Re: how to have sql server generating primary keys oninsertion of record set

    how many columns in the table and how many are you passing in?
    you have to pass in 1 less than the sum of all the columns

    Make sure you don't have an extra comma somewhere
    SQLMenace Guest

  6. #5

    Default Re: how to have sql server generating primary keys oninsertion of record set

    Hi

    well i tried this example:

    i have a table called productinfo with the columns: productnr, prodctname,
    version, build and desscription.

    when creating an insertion form with the coldfucsion insertion wizard i take
    out the productnr of the listed columns when having to select which columns i
    want to create frms for, because of course i dont wnat the key to be read in.
    Therefore i have 5 columns and i am reading in 4 coliumns, ust like you said.
    Still im getting the same error ?!?!

    surfinjay Guest

  7. #6

    Default Re: how to have sql server generating primary keys oninsertion of record set

    i got the probem!

    Dreamweaver did not update the query where as i had already changed the form.
    SO now i got it all roight.

    thx anyway
    Jay
    surfinjay Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139