#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0

    Unhappy Column unknown error


    Hey guys,
    I am using firebird Db in java/swing and i am running into a problem, i have a table named "TBLCASHTRANSACTION" which has a column name "LOGINID". I have a text field named "textField_1" in which i would enter the LoginId and afterwords when i run this query :

    SELECT * FROM TBLCASHTRANSACTION WHERE LOGINID = "+ textField_1.getText();

    I get this error:


    org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544569. Dynamic SQL Error
    SQL error code = -206
    Column unknown
    SSK0050606111535350002490
    At line 1, column 50


    Where SSK0050606111535350002490 is the loginid i entered in the textfield. What could be the problem. Please help .

    Thanks,
    Harry
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    Paris Uppland
    Posts
    2,378
    Rep Power
    391
    Enclose the search value in ' ', i.e.

    Code:
    "SELECT * FROM TBLCASHTRANSACTION WHERE LOGINID = '"+ textField_1.getText() + "'";

    Comments on this post

    • mariuz agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0
    Originally Posted by swampBoogie
    Enclose the search value in ' ', i.e.

    Code:
    "SELECT * FROM TBLCASHTRANSACTION WHERE LOGINID = '"+ textField_1.getText() + "'";

    K man thanks i`ll try this
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    3
    Rep Power
    0
    swampBoogie Thanks your the man
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    43
    Rep Power
    4
    It would be even better to use a parametrized query using parameters. You don't have to take care on the enclosed quotes at all then.

    Comments on this post

    • clivew agrees : Especially when dealing with login as it prevents SQL injection
    • mariuz agrees

IMN logo majestic logo threadwatch logo seochat tools logo