Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Can any1 Help?

    Hi
    Everytime i run the following code, i get the following error message:

    SQL Exception:java.sql.SQLException:[Microsoft][ODBC Microsoft Access Driver]
    Syntax error (missing operator) in query expression

    if (e.getSource() == updateManager) {

    String name1 = updateManagerFirstName.getText() ;
    String name2 = updateManagerLastName.getText() ;
    String dept = updateManagerDept.getText() ;

    if (name1.equals("")) {
    JOptionPane.showMessageDialog(null,"Enter Manager's First Name") ;
    }
    else if (name2.equals("")) {
    JOptionPane.showMessageDialog(null,"Enter Manager's Second Name") ;
    }
    else if (dept.equals("")) {
    JOptionPane.showMessageDialog(null,"Enter Manager's Department") ;
    }
    else {
    final String url = "jdbc:odbc:EmployeeD" ;

    // this is where the problem is, sql doesnt like this
    sythax.......

    String sSQL = "UPDATE Manager SET FirstName = '"+name1+"' WHERE"+
    "FirstName = '"+nameUpdate1+"' AND SET SecondName =
    '"+name2+
    "WHERE SecondName = '"+nameUpdate2+"' AND SET Department =
    '"+dept+
    "WHERE Department = '"+departUpdate+"'" ;

    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection(url) ;
    Statement st = con.createStatement () ;
    int rec = st.executeUpdate(sSQL) ;
    JOptionPane.showMessageDialog(null,"Manager Updated") ;
    System.exit(0) ;
    st.close();
    con.close();
    } // end of try statement
    catch (ClassNotFoundException f ) {
    JOptionPane.showMessageDialog(null,"failed to load JDBC/ODBC driver");
    JOptionPane.showMessageDialog(null,"class error: " + f);
    }
    catch (SQLException f ) {
    JOptionPane.showMessageDialog(null,"Unable to connect");
    JOptionPane.showMessageDialog(null,"SQL Exception: " + f);
    }
    } //end of else
    } // end of if upDateManager

    xcles Guest

  2. Similar Questions and Discussions

    1. any1 can explain a puppeting of sprites to me ?
      Hi all.. I see that many of you makes channel a puppet and then create on stage as many sprites as wanted and there's anothing in timeline right...
  3. #2

    Default Re: Can any1 Help?

    You're problem is your sql statement. The basic UPDATE statement has only (1)
    SET and (1) WHERE Clause. For example

    UPDATE yourTable
    SET someTextColumn = 'someTextValue',
    someNumberColumn = someNumberValue
    WHERE someID = someNumericID AND
    someTitle = 'some text string'

    Notice how there is only (1) "set" and (1) "where" clause. See also
    [url]http://www.w3schools.com/sql/sql_update.asp[/url]

    mxstu Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139