>*lcPermId = alltrim(companyinfo.PermID) && removed for testing >lcPermID = '1178072' >lnProgramYear = companyinfo.yearproduced >lcRawTable = addbs(fileloc) + "surveys\RawData" + transform(lnProgramYear) + '.dbf' > >lcConnectionString = "DRIVER=SQL Server;SERVER=PAG-SQLSERVER;" + ; > "UID=DonF;APP=Microsoft Visual FoxPro;" + ; > "WSID=TPD284;DATABASE=TRPSurvey;Trusted_Connection=Yes" >lnHandle = sqlstringconnect(m.lcConnectionString) >lcSQL = "select * " + ; > "from TRPSurvey" + "..exported " + ; > "where lcPermID = alltrim(PermID)" > >sqlexec(m.lnHandle,lcSQL,"crsImport") >sqldisconnect(m.lnHandle) >>
** 1. use lcPermID as parameter lcSQL = "select * " + ; "from TRPSurvey" + "..exported " + ; "where PermId = ?m.lcPermID" ** 2. Direct use of lcPermID lcSQL = "select * " + ; "from TRPSurvey" + "..exported " + ; "where PermId = '"+m.lcPermID+['] *** SQLEXEC() sqlexec(m.lnHandle,lcSQL,"crsImport")Also ALWAYS check what SQLEXEC returns. That way you will have information WHY that statement is not run:
IF sqlexec(m.lnHandle,lcSQL,"crsImport") < 0 AERROR(laError) MessageBox(laError[1,2]) ENDIF