Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
.Open("select * from tbllocation where ID like tblclient2 like NUMBER where expiration = '" & Label4.Text & "' and status = '" & "not expired" & "'", cn, 2, 3)
Posted

You have included 2 where clauses, only 1 is allowed

Should be

select * from tbllocation where ID like tblclient2 like NUMBER or expiration = '" & Label4.Text & "' and status = '" & "not expired" & "'"

or

select * from tbllocation where ID like tblclient2 like NUMBER and expiration = '" & Label4.Text & "' and status = '" & "not expired" & "'"
 
Share this answer
 
Comments
Member 10791395 3-Sep-14 23:54pm    
this is the table i have,
and i want to select the ID = NUMBER where the number expiration = label4.text and status = not expired.

im using vb.net and MS access for table.

tblclient2
NUMBER
clients
location
quantity
installation
expiration
size
status



tbllocation
ID
location
no_unit
avai_unit


thank you,
Maciej Los 11-Dec-14 16:17pm    
Yeah! Only one Where statement is allowed.
+5!
Here is Query Syntax please add your columns name and values according to your requirements.

SQL
select * from tbllocation where ID like '%GIVE ANY ID HERE%' --PLEASE USE [AND OR] HERE 
OR tblclient2 like '%GIVE NUMBER HERE%' 
AND expiration = 'YOUR TEXT HERE' and status = 'not expired'


if any issue then please let me know.

Thanks
 
Share this answer
 
Comments
Member 10791395 3-Sep-14 23:55pm    
this is the table i have,
and i want to select the ID = NUMBER where the number expiration = label4.text and status = not expired.

im using vb.net and MS access for table.

tblclient2
NUMBER
clients
location
quantity
installation
expiration
size
status



tbllocation
ID
location
no_unit
avai_unit


thank you,
MuhammadUSman1 4-Sep-14 1:20am    
SELECT * FROM tblclient2 t1 join tbllocation t2 on t1.Number = t2.ID and t1.expiration = lable4.text and status = 'not expired'

//it will select all data from both tables where id is equal Number and expriation is equal your give value and status is equal 'not expirde'.

if any issue in query understanding then let me know.
Thanks
->M.U
MuhammadUSman1 4-Sep-14 1:19am    
SELECT * FROM tblclient2 t1 join tbllocation t2 on t1.Number = t2.ID and t1.expiration = lable4.text and status = 'not expired'

//it will select all data from both tables where id is equal Number and expriation is equal your give value and status is equal 'not expirde'.

if any issue in query understanding then let me know.
Thanks
->M.U
Member 10791395 4-Sep-14 2:01am    
sir its Syntax error in FROM clause.
MuhammadUSman1 4-Sep-14 3:13am    
Please post error here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900