473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Bind multiple selections to a query

I'm looking for that elusive .net time saving magic.

I have an application that presents a list of items which the user can
select from. A CheckBoxList works great for that, but I want to query
a database based on their selections.

I'm forced to dynamically building a SQL statement in a method I could
have done easily in classic ASP:

SELECT fields FROM tablename WHERE ID IN (value1,value2....)

where the values correspond to the boxes checked in the CheckBoxList
control.

With all the hype about the .net revolution from MS, shouldn't there
be a better way? I'm hoping to just say "select records whose ID
numbers correspond to the boxes checked" without the grind of building
and testing SQL strings with code.

Do I need to wait for .net 3.0?

John
Nov 18 '05 #1
2 1422
> I'm forced to dynamically building a SQL statement in a method I could
have done easily in classic ASP:
I have no idea to what this is referring, as you didn't mention it (you only
mentioned a CheckBoxList). But I can tell you this: You're not forced to do
anything. In .Net, there are about a dozen ways to get data from a database,
and a dozen ways to bind it to a Control.

I used Classic ASP from the time it first emerged, and I would never go
back. Yes, I had to work very hard for a long time to learn .Net. But now I
would never look back. In Classic ASP, you would have had to create an
instance of (at least) a Connection, probably a RecordSet, and execute your
query. Then you would have had to hand-write all the ASP/HTML code to build
a table and/or a set of Checkboxes, and then wire them up by hand to the
appropriate fields in the RecordSet, possibly work out a way for the
Checkboxes to retain their values if the page was posted back to itself,
etc. I have to believe that the only reason you find that "easy" is that you
already know how to do it, and don't like the work involved in learning this
new, powerful, but complex technology. But learning new technologies is a
requirement in this business!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"John Hoge" <jh******@yahoo.com> wrote in message
news:d0*************************@posting.google.co m... I'm looking for that elusive .net time saving magic.

I have an application that presents a list of items which the user can
select from. A CheckBoxList works great for that, but I want to query
a database based on their selections.

I'm forced to dynamically building a SQL statement in a method I could
have done easily in classic ASP:

SELECT fields FROM tablename WHERE ID IN (value1,value2....)

where the values correspond to the boxes checked in the CheckBoxList
control.

With all the hype about the .net revolution from MS, shouldn't there
be a better way? I'm hoping to just say "select records whose ID
numbers correspond to the boxes checked" without the grind of building
and testing SQL strings with code.

Do I need to wait for .net 3.0?

John

Nov 18 '05 #2
Kevin,

Is there a technique that you can think of to pull information from a
database based on the (possibly multiple) selections from a
CheckBoxList?

The Classic ASP method would be to build a SQL statement string
manually, using the IN construct.

SELECT fieldlist from DATABASE where PRIMARYKEYFIELD IN
(valueA,valueB....)

Is there some .net way of passing an array of parameters to a database
to avoid this?

Thanks,
John
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: jason | last post by:
I could sure use some conceptualization and query help with a Page Watch System I am building in Access 2000 and Asp. I need to cycle through databae and generate a compiliation query email that...
3
by: arthur-e | last post by:
I can filter a query for a report on a field of a subform BUT now.... I'd like to be able to select more than one item in a multi-list box to select all the records. ALSO to use two fields (or...
4
by: Therese A. Sorna | last post by:
Hello all... I am using Access 2002, and am trying to find a way for a user to be able to select multiple entries from a drop-down list. I am hoping that given a list as such: a b c d
1
by: Mark | last post by:
My Category and Product tables look like: TblCategory CategoryID Category TblProduct ProductID CategoryID Product
1
by: | last post by:
Hi guys, i have a multiple select list box on my form, and it saves the selections I make into the field just fine., but when i open the form on an existing record, it does not show up the...
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
4
by: carl.barrett | last post by:
Hi, I have a list box that displays 2 columns. Behind it sits a query with five columns. These are Column1 (DOB), column2 (a concatenated string of Surname Forname, Title), Column3 (Surname),...
3
by: scott | last post by:
Hello all, I am ripping my hair out over this and maybe someone could help. I have a site that has groups and subgroups of those groups that all have int id's. I am trying to have a...
1
by: Marisa | last post by:
Hi. I am new to C#, and I am having trouble getting the multiple selection of listbox to work. I have an asp.net web form, and I need two listboxes which are filled with an access table. I have...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.