Results 1 to 2 of 2

Thread: User created SQL queries

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    10

    User created SQL queries

    Hello fellowVBites

    I am working with VB 6

    This is a very general query for me as I am quite new to it all

    Is there a way that sql queries can be user constructed ?
    Is there a way that the user (unknowingly) creates the sql query at run time,as opposed to then just initiating a pre-written sql query .
    I will try and explain as clearly as possible,so please dont run off into the mountains


    The idea is that the user clicks into the menu in a ListBox,from this an sql statement is created,the relevent tables and fields are scanned and extracted and the result is placed onto a grid.

    Lets say I have a small access database that gives me a table with the following fields used to gather info about marathon runs.
    date
    title
    location
    marathon title
    number of entrants
    distance
    winner
    second

    I would then set up a series of ListBoxes to allow the user to query the database
    I suppose the question I am asking is whether it is possible for the user(via some input mechanism like a list box) to be able to construct the sql query "on the fly".i.e a fresh sql query instituted into code everytime a series of requests were made by the user.

    Is this possible??? or am I barking up the wrong tree
    Kind Regards
    Tommy

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: User created SQL queries

    It certainly is possible - an SQL statement is just a string, so all you need to do is write code which builds the string as apt.

    There is an example of how to do that in the "Further Steps" article of the FAQs (direct link in my signature), within the "Search" section.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width