Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2005, 07:44 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default Running a query

This may be a trivial question, and I'm sorry for asking it if it is, I have a Query called MAINquery, and it takes a few arguements,

MAINquery(ByVal board As String, ByVal chassis As String, ByVal hDDType As String)

I've put the query into a function, now my question is how do I run the query using the values selected by the user e.g.
I have 3 dropdown lists called Board, Chassis and HddType, the user selects values from the dropdown and then hits a button. Its when this button is hit that I would like my query to run taking the selected values from the 3 dropdown lists.

Any assistance would be appreciated

 
Old April 29th, 2005, 09:57 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Is this a .NET object, or something stored in the database management system?
 
Old April 29th, 2005, 10:05 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is a .Net object

 
Old May 2nd, 2005, 09:48 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Are you talking database query or just a function in code? (Your use of the term "query" is a little confusing here.)

Presumably your function "MAINQuery" lives in a class somewhere, so you'll need to instantiate that class and then you can call the function on it. Or you can make the function "Shared" so that you don't need a class instance to call it.

-Peter
 
Old May 3rd, 2005, 03:11 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Its a function in code, I know how to call a function but the problem is that its taking arguements from 3 dropdown lists so it can check those values against a database its this part that im not too sure about

 
Old May 3rd, 2005, 05:42 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you looking for the Selected Text property of the dropdown,
Or the issue is user can exclude any dropdown in the search condition.

 
Old May 3rd, 2005, 06:30 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm looking for the Selected Text property, but I need to store the value somewhere do I not? Like I said before I have 3 dropdown lists and the user needs to select values from each dropdown, the selected values would then be used to query the database and return an x number of results, but I'm not sure how to go about it.

 
Old May 3rd, 2005, 07:32 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You don't need to store the value anywhere, just pass them into the function:

MAINquery(ddlBoard.SelectedValue, ddlChassis.SelectedValue, ddlHDDType.SelectedValue)

-Peter
 
Old May 3rd, 2005, 07:58 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter, I'll give that a try, and I'll post back later to tell everyone else if its worked

D

 
Old May 3rd, 2005, 08:19 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay I gave it a try and I'm not sure if its working, as when I click the Submit button (I've got the onClick event and AutoPostBack sorted) but it doesn't seem to populate to DDL4, my code is below.
Code:
Sub Button1_Click(sender As Object, e As EventArgs)
    DropDownList4.Datasource = MAINquery(Chassis1.SelectedValue, Board1.SelectedValue, HDDType1.SelectedValue)
    DropDownList4.DataBind()
End Sub
I had to rename the DropDownLists as some of the names used were causing conflicts

D






Similar Threads
Thread Thread Starter Forum Replies Last Post
Running an Access Query from ASP arholly Access ASP 0 January 25th, 2008 03:31 PM
Running query... Question... RinoDM SQL Server 2000 2 July 26th, 2007 08:49 AM
Running a Query anukagni Access 3 May 5th, 2006 12:16 AM
running out of field in query building yixchen Access 2 December 19th, 2005 10:19 AM
Running an SQL query in VBA... Augusta Access VBA 3 December 1st, 2004 05:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.