Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How i will retrive data based variable condition
Message
From
04/06/2005 10:05:17
 
 
To
04/06/2005 07:44:36
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01020224
Message ID:
01020228
Views:
16
You need to construct a string which represents the SQL query like this:
cCod = '1'
cBranch = 'Brn1'

IF Thisform.Check1.Value = 1
   cCondition = 'ItmMast.ItemCod = cCod'
Else
   cCondition = 'ItmMast.ItemBrn = cBranch'
Endif

cSql = "Select ItmCod, ItmDes From ItmMast Where " + cCondition

*- Then execute the sql statement using macro substitution
&cSql
Or to construct a SQL command without Macro Substitution you can try this:
cCod = '1'
cBranch = 'Brn1'

IF Thisform.Check1.Value = 1
   Select ItmCod, ItmDes From ItmMast Where ItmMast.ItemCod = cCod
Else
   Select ItmCod, ItmDes From ItmMast Where ItmMast.ItemBrn = cBranch
Endif
Glenn


>

>Hi Experts,
>
>I have an sql Query statement, i want retrive data based on condition like
>
>cCod = '1'
>cBranch = 'Brn1'
>
>IF Thisform.Check1.Value = 1
> cCondition = 'ItmMast.ItemCod = cCod'
>Else
> cCondition = 'ItmMast.ItemBrn = cBranch'
>Endif
>
>'Select ItmCod, ItmDes From ItmMast Where cCondition'
>
>How i will i convert this to an Sql Server statement.
>
>Please i need somebody's kind help in the regard
>
>Thanks in advance
>
>Regards
>
>Abdulla
Previous
Reply
Map
View

Click here to load this message in the networking platform