1

This is my code

string stR = "INSERT INTO CHECKINOUT (USERID,CHECKTIME,CHECKTYPE,VERIFYCODE,SENSORID,WorkCode) " +
                            " SELECT a.USERID,c.CHECKTIME,c.CHECKTYPE,c.VERIFYCODE,c.SENSORID,c.WorkCode " +
                            " FROM USERINFO a " +
                            " JOIN [MS Access;DATABASE=" + open.FileName + "].USERINFO b " +
                            " ON a.BadgeNumber=b.Badgenumber " +
                            " JOIN [MS Access;DATABASE=" + open.FileName + "].CHECKINOUT c " +
                            " ON  b.USERID=c.USERID " +
                            " WHERE NOT EXISTS " +
                            " (SELECT a.USERID,c.CHECKTIME,c.CHECKTYPE,c.VERIFYCODE,c.SENSORID,c.WorkCode " +
                            " FROM USERINFO a " +
                            " JOIN [MS Access;DATABASE=" + open.FileName + "].USERINFO b " +
                            " ON a.BadgeNumber=b.Badgenumber " +
                            " JOIN [MS Access;DATABASE=" + open.FileName + "].CHECKINOUT c " +
                            " ON  b.USERID=c.USERID)";

I got exception error "Syntax error in FROM clause"

Note: I already exported all ms access tables to ms sql 2000 database and this script is working fine with no error, but with ms access I receive this kind of error, This is the first time I'm using ms access as back end, this is an old program in my office that I need to fix error.

3
  • I guess the join syntax is slightly different in access as compared with SQL Server. It need "Inner" and "Outer" keywords for joining. You may check this by creating a SQL in Access Query designer and check how its syntax generating these queries Commented Mar 27, 2014 at 6:45
  • Please see stackoverflow.com/a/18968078/20371 Commented Mar 30, 2014 at 16:18
  • possible duplicate of Access query error ("syntax error in from clause") Commented Mar 30, 2014 at 16:18

1 Answer 1

0

My first question is which FROM clause is failing. I would test each portion separately. Does the query work if you remove the WHERE NOT EXISTS clause? If so then the problem is in the subquery WHERE NOT EXISTS is referencing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.