Results 1 to 4 of 4

Thread: [SQL2000] insert query

  1. #1

    Thread Starter
    New Member TINEIZVO's Avatar
    Join Date
    Apr 2007
    Location
    Zimbo
    Posts
    4

    [SQL2000] insert query

    Code:
    myCommand = New SqlCommand("INSERT INTO accounts 
    (LAST_NAME, FIRST_NAME, ADDRESS, TELEPHONE, FAX, COUNTRY, E_MAIL) 
    VALUES (dataset.LAST_NAME, dataset.FIRST_NAME, dataset.ADDRESS, 
    dataset.TELEPHONE, dataset.FAX, dataset.COUNTRY, dataset.E_MAIL)", 
    myConnection)
    thats my query how do i solve an error "the name 'LAST_NAME' is not permitted in this context. only constants, exprations and vriables are allowed. coumn names are not allowed"
    Last edited by Hack; Apr 13th, 2007 at 06:45 AM.

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: [SQL2000] insert query

    First thing I want to say you that do not use UnderScope in the field of the table.
    Use FIRST_NAME AS FirstName same fro the LastName.

    And for the problem check your dataset.

  3. #3

    Thread Starter
    New Member TINEIZVO's Avatar
    Join Date
    Apr 2007
    Location
    Zimbo
    Posts
    4

    Re: [SQL2000] insert query

    code or sql suggestions would be more welcome which include detailed explanations

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [SQL2000] insert query

    It looks like the problem is dataset - I presume this is an object in your code, rather than a table in your database.

    You cannot use variables/objects inside (SQL) strings, you need to append the values to the string instead.

    I don't use VB.Net, but I assume that what you need is something like this:
    Code:
    .. VALUES ('" & dataset.LAST_NAME & "', '" & dataset.FIRST_NAME & "', ..

Posting Permissions

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



Click Here to Expand Forum to Full Width