0

I have a problem in retrieving data from database.. I have 3 textboxes and textbox1 is for applicant_num, textbox2 is for applicant_name and textbox3 is for Lot_num and i want to view those data in listview.. how can I get the data from database using vb.net? Hope you can help me.. thanks.

Code is here:

dim sql as string = "select * from Pambujan where app_num = '" & textbox1. text & "',  app_name = '" & textbox2. text & "',  lot_num = '" & textbox3. text &"'"

1 Answer 1

1

The syntax for accessing the Text property of the text boxes is incorrect. Also, the dynamic WHERE clause being generated should use 'AND' instead of commas. Something like this:

dim sql as string = "SELECT * from Pambujan WHERE app_num = '" & textbox1.Text & "' AND app_name = '" & textbox2.Text & "' AND lot_num = '" & textbox3.Text &"';"
Sign up to request clarification or add additional context in comments.

1 Comment

AND you should always use parametrized queries to avoid SQL injection, too! ALWAYS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.