[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

Single Database, multiple queries!

Hello!

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!

NJ
 
0
njacques
Asked:
njacques
  • 2
  • 2
1 Solution
 
kGeniusCommented:
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.
<FINISH>
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
GridView1.DataBind()

(change gridview1 to the ID of your control)

That should do...

kGenius



0
 
njacquesAuthor Commented:
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 "?" ?

Thanks

NJ
0
 
kGeniusCommented:
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)

kGenius
0
 
njacquesAuthor Commented:
I does work both ways! thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now