SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    insert error (command object)

    hello,
    i am working on an insert command on an ASP page, with the command being

    Code:
    create_phonebook.CommandText = "INSERT INTO dbo.sms_phonebook ( Nickname,Phone_number)  VALUES (" + Replace(create_phonebook__t1, "'", "''") + "," + Replace(create_phonebook__name1, "'", "''") + ")
    however i get the error below. What is wrong ?

    thanks

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC SQL Server Driver][SQL Server]The name 'afrika' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.

    /welcome/welcome

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    create_phonebook.CommandText = "INSERT INTO dbo.sms_phonebook ( Nickname,Phone_number) VALUES ( '" + Replace(create_phonebook__t1, "'", "''") + "', '" + Replace(create_phonebook__name1, "'", "''") + "' )"
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot Rudy, however with this type of command text, it becomes a command object and not a stored proceedure ?

    rgds

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    i'm sorry, i don't understand the question

    it's a query, or...?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No it is a stored proceedure that is being called from an ASP page, Howver i stayed up late into the night and got it sorted out.

    thanks once again for your assistance.

    I just learnt another way of using the command object your wrote above

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    i didn't write a command object, i corrected a syntax error in your sql (missing quotes around a string value)

    i don't do command objects, i don't even know what they are
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh ok, thanks Rudy

    Command objects are an alternative to inserts, update, and delete in ASP objects, that use transactions. :-)


Bookmarks

Posting Permissions

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