Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;;Open the Databases #DEFINESUBROUTINE dataopen() ;; Allocate SQL environment and handles db=qAllocEnv() if db==-1 errcode=qLastCode() message("TM DB qAlloc Failed",errcode) endif tmdbc=qAllocConnect(db) if tmdbc==-1 errcode=qLastCode() message("TM DB Conn Alloc failed",errcode) endif ;; Set opts for SQL Connections qSetConnOpt(tmdbc, 103, 1, 0) ;;Connect to DBs tmcode=qConnect(tmdbc,"tm","","") If (tmcode != @qSuccess) && (tmcode != @qSuccessInfo) Message("TM DB qConnect failed", tmcode) Exit Endif #ENDSUBROUTINE ;Open and get some data from out db #DEFINESUBROUTINE dataget() tmstm=qAllocStmt(tmdbc) tmSQL=StrCat("SELECT SeqNum,Time,Date,AP,CompanyName,Location,TM,Sales,Emp,Day FROM tm WHERE SeqNum=1") tmget=QExecDirect(tmstm,tmSQL) If (tmget != @qSuccess) && (tmget != @qSuccessInfo) Message("TM DB Edit qExecDirect failed", tmget) Exit Endif tmfet=qFetch(tmstm) if tmfet==@qNoData err=StrCat("Record for Appt SeqNum: ",seqnum," not found!!") Message("Error",err) Exit endif if (tmfet != @qSuccess) && (tmfet != @qSuccessInfo) Message("TM DB Edit qFetch failed", tmfet) Exit Endif getcode = qGetData(tmstm, 1, "seqnum", 80) getcode = qGetData(tmstm, 2, "time", 80) getcode = qGetData(tmstm, 3, "date", 80) getcode = qGetData(tmstm, 4, "ap", 80) getcode = qGetData(tmstm, 5, "compname", 80) getcode = qGetData(tmstm, 6, "location", 80) getcode = qGetData(tmstm, 7, "tm", 80) getcode = qGetData(tmstm, 8, "sales", 80) getcode = qGetData(tmstm, 9, "emp", 80) getcode = qGetData(tmstm, 10, "dayweek", 80) code=qFreeStmt(tmstm,1) #ENDSUBROUTINE #DEFINESUBROUTINE dataup(update) tmstm=qAllocStmt(tmdbc) try=0 q="'" c="," ;sql="INSERT INTO tm (Time) VALUES (12:00)" sql="UPDATE tm SET SeqNum='1',Date='123',Time='12:00',AP='P',CompanyName='acme',Location='norc',TM='twm',Sales='dk',Emp='5',Day='wed' WHERE SeqNum='1'" ;sql=StrCat(sql,q,rtime,q,c,"Date=",q,rdate,q,c,"AP=",q,rap,q,c,"CompanyName=",q,rcname,q,c,"Location=",q,rloc,q,c,"TM=",q,rtm,q,c,"Sales=",q,rsales,q,c,"Emp=",q,remp,q,c,"Day=",q,rday,q," WHERE SequenceNum=",q,seqnum,q) :sql set=qExecDirect(tmstm,sql) If (set != @qSuccess) && (set != @qSuccessInfo) if try==0 try=1 goto sql endif Message("TM DB qExecDirect failed", set) Exit endif ;code=qTransact(db,0,@qCommit) code=qFreeStmt(tmstm,1) break default ;sql="SELECT notes,key FROM notes" ;notesget=qExecDirect(outstm,sql) ;notesF=qFetch(outstm) ;getcode=qGetData(outstm,1,"notes",255) ;getcode=qGetData(outstm,2,"key",2) ;code=qFreeStmt(outstm,1) break #ENDSUBROUTINE
#DEFINESUBROUTINE dataup() tmstm=qAllocStmt(tmdbc) sql="UPDATE tm SET SeqNum='1',Date='123',Time='12:00',AP='P',CompanyName='acme',Location='norc',TM='twm',Sales='dk',Emp='5',Day='wed' WHERE SeqNum='1'" set=qExecDirect(tmstm,sql) if (set != @qSuccess) && (set != @qSuccessInfo) err=qerror(hstmt,2) message("qExecDirect Failed. Driver returned:",err) Exit endif code=qFreeStmt(tmstm,1) Return #ENDSUBROUTINERun the above code then post the results here.
37000 [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
sql="UPDATE tm SET SeqNum='1',Date='123',Time='12:00',AP='P',CompanyName='acme',Location='norc',TM='twm',Sales='dk',Emp='5',Day='wed' WHERE SeqNum='1'"Does the above SQL string work in Access?
Article ID: W16599
File Created: 2005:02:18:12:21:36
Last Updated: 2005:02:18:12:21:36