locked
Visual Studio database error RRS feed

  • Question

  • When I try to insert values in the table login that I created,the following error occurs(the datatype of username and password is varchar(50)). IDK whether this is the right forum to post this question or not. Pls help!

    SQL Execution Error.
    Executed SQL statement:INSERT INTO login(username,password)
    VALUES(abc,xyz);
    ERROR Source: .NET SqlClient Data Provider
    Error Message: Invalid column name 'abc'.
    Invalid column name 'xyz'.

    • Moved by Amanda Zhu Thursday, May 30, 2013 6:10 AM not VS general forum issues and not sure which appropriate forum this thread can be moved to
    Wednesday, May 29, 2013 3:59 PM

Answers

  • Hey Konrad..Thanks!

    That was so stupid of me!

    kale20.

    Friday, May 31, 2013 12:59 PM

All replies

  • Hi,

    I think you meant a query like:
    INSERT INTO login (username, password) VALUES ('abc', 'xyz')

    Please be aware that the abc and xyz was put into quotes.

    Without these quotes the server looks for elements with names abc and xyz which does not exist.

    With kind regards,

    Konrad

    Wednesday, May 29, 2013 4:17 PM
  • Put a space after the table name 'login', put brackets around the table name, and put single quotes around the strings.

    INSERT INTO [login]  ('username','password')   VALUES('abc','xyz');


    jdweng

    Wednesday, May 29, 2013 4:22 PM
  • Hi Joel,

    - you can put names into brackets e.g. [login], [username] or [password] but that is not required because these are not reserved words. So it would be required if you had a table called IDENTITY or so.
    A list of all reserved words can be found at http://msdn.microsoft.com/en-us/library/ms189822.aspx

    - Do not put names into quotes. You put text into quotes that you want to give to the server as core strings. But username and password are field names and you get an error if you put them into quotes.

    With kind regards,

    Konrad

    Wednesday, May 29, 2013 4:41 PM
  • Hey Konrad..Thanks!

    That was so stupid of me!

    kale20.

    Friday, May 31, 2013 12:59 PM