>>>>*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") >>>>>>
>>>IF sqlexec(m.lnHandle,lcSQL,"crsImport") < 0 >>> AERROR(laError) >>> MessageBox(laError[1,2]) >>>ENDIF >>>>>
>>lcSQL = "select * " + ; >> "from TRPSurvey" + "..exported " + ; >> "where ltrim(rtrim(PermID)) = " + lcPermID >> >>IF sqlexec(m.lnHandle,lcSQL,"crsImport") < 0 >> AERROR(laError) >> MessageBox(laError[1,2]) >>ENDIF >>>
>lcPermID = [123456] >lcSQL = "select * " + ; > "from TRPSurvey" + "..exported " + ; > "where ltrim(rtrim(PermID)) = " + lcPermID ><pre> > >The SQL server will get this command: ><pre> >select * from TRPSurvey..exported where ltrim(rtrim(PermID)) = 123456 >>
>lcPermID = [123456] >TEXT TO lcSQL NOSHOW TEXTMERGE > select * from TRPSurvey..exported > where ltrim(rtrim(PermID)) = '<<lcPermID>>' >ENTEXT ><pre> > >Did you see the difference? > >The SQL server will get this command now: ><pre> >select * from TRPSurvey..exported where ltrim(rtrim(PermID)) = '123456' >>
>lcPermID = [123456] >TEXT TO lcSQL NOSHOW TEXTMERGE > select * from TRPSurvey..exported > where ltrim(rtrim(PermID)) = ?m.lcPermID >ENTEXT >OK, I see your point. Since I am not real comfortable yet with the ?variable or <