Here's my SQL Statement:

SELECT * FROM tblHeader WHERE Requestor='"&label1.text&"'

Why doesn't it work?

Recommended Answers

All 10 Replies

Here's my SQL Statement:

SELECT * FROM tblHeader WHERE Requestor='"&label1.text&"'

Why doesn't it work?

Hi Alphard,

may be becuase of last comma issue...
SELECT * FROM tblHeader WHERE Requestor='" & label1.text & "'"

Hi Alphard,

may be becuase of last comma issue...
SELECT * FROM tblHeader WHERE Requestor='" & label1.text & "'"

I did that but it doesn't seem to work..

then please post the exact error. so that we can find out where the problem lies.

then please post the exact error. so that we can find out where the problem lies.

Hi Piya!

Here's the error:
Invalid text or symbol.
Error in WHERE clause near'"
Unable to parse query text.

Post your code. Use following syntax if column type is non-numeric,

str="SELECT * FROM tblHeader WHERE Requestor='" &  Text1.Text & "'"

For numeric type,

str="SELECT * FROM tblHeader WHERE Requestor=" &  Text1.Text

Post your code. Use following syntax if column type is non-numeric,

str="SELECT * FROM tblHeader WHERE Requestor='" &  Text1.Text & "'"

For numeric type,

str="SELECT * FROM tblHeader WHERE Requestor=" &  Text1.Text

I'm doing it through Query Builder is it possible to that there?

no it is not possible there you have to specify the exact string or text instead of Label1.Text.

Piya: no it is not possible there you have to specify the exact string or text instead of Label1.Text.

Why not? There is no problem with Label's Text with value.

Hello Sir,

I am not saying that there's any problem with Label's Text with value
I wrote this because Alphard is using Query Builder which I don't think takes values from Label or TextBox.(I may be wrong, but I have suggested what I have practised). I use Query Builder for testing my queries and that never takes values from Labels etc.

no it is not possible there you have to specify the exact string or text instead of Label1.Text.

Thanks Piya! Its already working...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.