Subject Re: SQLDataSet question
From Boris Borzic <bb> <Boris Borzic <bb>>
Date Fri, 25 Jan 2019 18:42:45 +0100
Newsgroups sqlexpress

You can use SQL params. Here is an example:

static function GetTotmastr( cPackSlip, nCarton, oConn )
   static oTM

   DEFAULT oConn TO DefaultSQLConnection()

   if oTM == NIL
      oTM := oConn:RDataSet("select
t.SHIP_VIA,t.SHIP_CNTRY,t.BOX_SIZE,t.TRACKTRACE,p.PO_TYPE from TOTMASTR t
(nolock) left join PICKHEAD p on t.PACKSLIP=p.PACKSLIP where t.packslip=?
and t.carton_n=?", {cPackslip, nCarton})
   else
      oTM:SetConnection(oConn)
      oTM:SQLParameters := {cPackslip, nCarton}
   endif

   oTM:FetchData(.t.)

   if oTM:eof()
      // should never happen!
      LogEvent("TOTMASTER not found:", cPackslip, nCarton)
   else
      DebugLog(cPackslip, nCarton, oTM:DataSet[1])
   endif

   Return oTM


--
Best regards,
Boris Borzic

http://xb2.net
http://sqlexpress.net
industrial strength Xbase++ development tools


"Adrian Wykrota" <adrian@wykrota.pl> wrote in
news:3u0vksxr8lycwpp.250120191205@daz17:

> It is posiible to reaload SQLDataSet object by adding sql clause
> ex.
>
> oData := SqlDataSet("SELECT Field1,Field2 FROM MyTable", oCon)
> (..some operations...)
> oData:SQLString = "SELECT Field1,Field2 FROM MyTable WHERE Field>5"
> oData:Execute()
> (...rest operations....)
> oData:SQLString = "SELECT Field1,Field2 FROM MyTable WHERE Field>1
> ORDER BY Field2 DESC"
> oData:Execute()
> (...rest operations....)


Recent messages in this thread
 
-# SQLDataSet question Adrian Wykrota 25-Jan-2019 06:05 am
.\# Re: SQLDataSet question (Current message) Boris Borzic <bb> 25-Jan-2019 12:42 pm