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.

invalid column name

Discussion in 'C#' started by bhuppi890109, Mar 18, 2011.

  1. #1
    hi i am creating the new website in visual 2010 with sql 2008..but i am facing some problem.
    i applied a button on a webpage with the insert querey into table
    SEMrush
    the querey is "insert into ddd values(abc,cbd)"

    but when i entered the button it shows the errors..
    invalid column name 'abc'
    invalid column name 'cbd'


    but it is only the entry into table. it is not the column name..
    so tell me where is the problem
     
    bhuppi890109, Mar 18, 2011 IP
    SEMrush
  2. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,681
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What is the structure of the table ddd?

    It is generally better to be explicit in your SQL anyway incase the table structure changes in the future
    INSERT INTO table_name (column1, column2, column3,...)
    VALUES (value1, value2, value3,...)
    Code (markup):
     
    AstarothSolutions, Mar 18, 2011 IP
  3. bhuppi890109

    bhuppi890109 Member

    Messages:
    1,337
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    48
    #3
    my table is

    id int
    name varchar(50)
    data varchar(MAX)
     
    bhuppi890109, Mar 18, 2011 IP
  4. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,681
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You are therefore trying to insert abc into an integer field and you are missing ' ' around the text to show it is text
     
    AstarothSolutions, Mar 18, 2011 IP
  5. bhuppi890109

    bhuppi890109 Member

    Messages:
    1,337
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    48
    #5
    no actually my exact querey is
    insert into ddd(name,data) values(abc, dkd);
     
    bhuppi890109, Mar 18, 2011 IP
  6. AstarothSolutions

    AstarothSolutions Peon

    Messages:
    2,681
    Likes Received:
    77
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Your still missing the ' ' around your text values
     
    AstarothSolutions, Mar 19, 2011 IP
  7. wsrinivas

    wsrinivas Member

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #7
    is not advisable to use "name", "data" as they are reserverd keywords I always use txtName, txtData that way you can have no problems

    hope this helps
     
    wsrinivas, Mar 21, 2011 IP
  8. jahbuzoreze

    jahbuzoreze Member

    Messages:
    46
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #8
    thanks everyone
     
    jahbuzoreze, Apr 3, 2011 IP
  9. miguelf

    miguelf Member

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    48
    #9
    You need quotes around the values so you example would be: insert into ddd values('abc','cbd')
     
    miguelf, Apr 7, 2011 IP
  10. unknownpray

    unknownpray Active Member

    Messages:
    3,832
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    70
    #10
    "insert into ddd values(abc,cbd)"
    Here you forgot to give single quote (') because charecter should write in single quote that is "insert into ddd values('abc','cbd')"
     
    unknownpray, Jul 1, 2011 IP