hello , Everybody.. Pleez i'm juz a beginner in asp

Discussion in 'C#' started by syida, Oct 3, 2007.

  1. #1
    sorry cause i have poor english..

    1) how to insert data in asp coding if the id is auto number?
    *is there is any key i have to do in my database?
    *Number of query values and destination fields are not the same.<--- what is the meaning ?????????
    i'm wrilly tension ....
     
    syida, Oct 3, 2007 IP
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if the field is auto number then you do not set a value otherwise you will get an error. Leave the field blank it will auto number
     
    AstarothSolutions, Oct 3, 2007 IP
  3. syida

    syida Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    how to catch the data means (id=autonumber) pnto the form automatically ?
    to upadate / delete process
     
    syida, Oct 4, 2007 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,680
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    if you are using an identifier field in MS SQL then use:

    SELECT SCOPE_IDENTITY() AS theid; to return the new id

    So your command would look something like:
    "INSERT INTO TableName (column1, column2) VALUES (value1, value2); SELECT SCOPE_IDENTITY() AS theid;"
     
    AstarothSolutions, Oct 4, 2007 IP
  5. kadesmith

    kadesmith Peon

    Messages:
    479
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Number of query values and destination fields are not the same.<--- what is the meaning ?????????

    This means that your SQL statement either has more/less values to insert than columns in the database. SQL may appear as this

    INSERT INTO table (column1, column2, column3) VALUES (column1, column2 column3)

    Notice that there is a missing comma after column2. This is an easy mistake to make.

    Try writing the SQL string to HTML with a
    response.write(strSQL)
    response.end

    This will allow you to evaluate your SQL
     
    kadesmith, Oct 5, 2007 IP