Dynamic SQL query

5 pts.
Tags:
Access Database
Dynamic SQL
SQL Query
VB.NET
Hi! I'm making an application in vb.net using MS Access as DB.. Nw in this, i want to do some complex stuff, that is dynamically making sql queries or in other words, changing the where clause according to user preference. The scenario let's say is...in a form the user can search for records thru 1) university name or 2) between 2 dates 3) through application ids... They can do each of this individualy or 1 n 2 together or 1 n 3 etc. Now instead of writing the sql query for each combination, do you think there is a way i can put in a flag value n get wateva the user wants to search frm n pass that to the where clause? Thank you so much!

Answer Wiki

Thanks. We'll let you know when a new response is added.

i try to understand your quest…..

as your ques you can make your query as like this………..

select (id) from university where date between #” date1 “# and #” date2 “# “;

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    Are you creating your queries in Access and then executing them from VB ?
    69,475 pointsBadges:
    report
  • Meandyou
    The only problem with allowing user to write the WHERE clause is they must use proper syntax. For example, is might be OK to allow the user to enter a NAME and you search on an equal condition. But your program is going to have to allow for a LIKE compare; and if it is a LIKE compare where does your program place the wilcards - Or do you leave that up to the user. Perhaps better to have multiple fields on the input screen:
    Beginning DATE (mm/dd/yy) _____  ending date (mm/dd/yy) ________
    OR
    date is exactly (mm/dd/yy) ________
    OR
    FULL name __________________
    OR
    name STARTS with ________________
    OR
    name contains ____________________
    or
    name ENDS with __________
    OR ... 
    5,220 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following