Single Database, multiple queries!

Posted on 2006-05-27
Last Modified: 2008-03-06

I am brand new to Visual Web Developper 2005.

However, i have been able to create nice stuff.

Here is what i am unable to do, or let's say almost.

i have a databound control (tested with Textbox and gridview, both same behaviour)

linked to an Acessdatasource control called "Library1"

The Library1 control access the Something.mdb

I have created a query that goes something like this

SELECT * FROM [Info] WHERE ([Path] LIKE '%' + ? + '%') ORDER BY [Cleanname] DESC

What i want to do is manage the ? value to put anything (by code) so that the databound control gets refresh to displays the new data.

I am able to specify what the default value for ? is, and that works.

I have also created some additional queries, that are in fact the same, but with different default values ?.

Is there a way to switch from a value, or from a query to an other, or create multiple connection to the something.mdb file with there own query? so that depending of a value in a dropdown, the user gets a refreshed database with correct being sown.

Hope you can help!

Question by:njacques
    LVL 7

    Accepted Solution

    Drop a dropdownlist onto the form. Select the datasource (create a new one that gets a list of the paths from you Info table: ie "SELECT DISTINCT [Path] FROM Info"

    In Library1
    Change the ? by a parameter like this
    "SELECT * FROM [Info] WHERE ([Path] LIKE '%' + @PathPart + '%') ORDER BY [Cleanname] DESC

    In the wizard (configure data source) you must define the parameters.
    Select as parameter source: Control
    ControlID: DropDownList1 (or the ID of your control)
    DefaultValue: if necessary.
    Look now in the HTML view what is has done: in your first DataSource there's a SelectParameters-tag provided!

    DoubleClick the DropDownList control and in the SelectedIndexChanged statement (code-behind) add

    (change gridview1 to the ID of your control)

    That should do...



    Author Comment

    Thanks! Work perfectly ; Consider that Comment to be Accepted...

    I now better understand the "Control" parameter source usage.

    Just a little question.

    I left the query as is:

    SELECT * FROM [Info] WHERE ([Path] LIKE '%' + ? + '%') ORDER BY [Cleanname] DESC

    why have you recommended to use:

    SELECT * FROM [Info] WHERE ([Path] LIKE '%' + @PathPart + '%') ORDER BY [Cleanname] DESC

    Where is the @PathPart  defined and what is its need versus "?" ?


    LVL 7

    Expert Comment

    Well the ? is not accepted in the SQL statement when using SQL 2000. There must be a parameter @blabla provided.
    For Access maybe the ? does work (had no idea, I do not use it...)
    So if it does you could use it your way.
    Can you try with the parameter and let me know if that works with Access? (just for knowing)


    Author Comment

    I does work both ways! thanks!

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now