473,395 Members | 1,471 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,395 software developers and data experts.

Using IN to fill DataTableAdapter.

I have a set of reports that use the graphically created dataset. In the
SelectCommand, I need to use "IN" in the where (SELECT FullName,
CheckInTime, CheckOutTime, Minutes FROM dbo.CheckIn Where Login IN (@People)
AND CheckInTime @CheckIn AND CheckOutTime < @CheckOut).

On the form, I have a listbox that should allow the user to select several
names and those names should be passed to the @People parameter. I can't
find a way to get that to work.

I can get a single name to work
(Me.CheckInTableAdapter.Fill(Me.dsClockIn.CheckIn,
lbPeople.SelectedValue.ToString, dtpStart.Value, dtpEnd.Value)).
Oct 14 '07 #1
3 1831
"Shawn" <sh**********@ccci.orgschrieb
>I have a set of reports that use the graphically created dataset. In the
SelectCommand, I need to use "IN" in the where (SELECT FullName,
CheckInTime, CheckOutTime, Minutes FROM dbo.CheckIn Where Login IN
(@People) AND CheckInTime @CheckIn AND CheckOutTime < @CheckOut).

On the form, I have a listbox that should allow the user to select several
names and those names should be passed to the @People parameter. I can't
find a way to get that to work.

I can get a single name to work
(Me.CheckInTableAdapter.Fill(Me.dsClockIn.CheckIn,
lbPeople.SelectedValue.ToString, dtpStart.Value, dtpEnd.Value)).
Create one parameter per selected item (eg named @person1 ... @personN), and
build the SQL like

... Login IN (@person1, @person2, @person3, @person4) ...

Or, if there might be a large number of selectable people, write them into a
temp table and change the sql to "...login in (select ID from
temptable)..."
Armin

Oct 14 '07 #2
I need to think about it, but I don't think either of those will work in
this situation.

"Armin Zingler" <az*******@freenet.dewrote in message
news:u0***************@TK2MSFTNGP06.phx.gbl...
"Shawn" <sh**********@ccci.orgschrieb
>>I have a set of reports that use the graphically created dataset. In the
SelectCommand, I need to use "IN" in the where (SELECT FullName,
CheckInTime, CheckOutTime, Minutes FROM dbo.CheckIn Where Login IN
(@People) AND CheckInTime @CheckIn AND CheckOutTime < @CheckOut).

On the form, I have a listbox that should allow the user to select
several
names and those names should be passed to the @People parameter. I can't
find a way to get that to work.

I can get a single name to work
(Me.CheckInTableAdapter.Fill(Me.dsClockIn.CheckIn ,
lbPeople.SelectedValue.ToString, dtpStart.Value, dtpEnd.Value)).

Create one parameter per selected item (eg named @person1 ... @personN),
and
build the SQL like

... Login IN (@person1, @person2, @person3, @person4) ...

Or, if there might be a large number of selectable people, write them into
a
temp table and change the sql to "...login in (select ID from
temptable)..."
Armin

Oct 14 '07 #3
"Shawn" <sh**********@ccci.orgwrote in message
news:ul**************@TK2MSFTNGP04.phx.gbl...
>I have a set of reports that use the graphically created dataset. In the
SelectCommand, I need to use "IN" in the where (SELECT FullName,
CheckInTime, CheckOutTime, Minutes FROM dbo.CheckIn Where Login IN
(@People) AND CheckInTime @CheckIn AND CheckOutTime < @CheckOut).

On the form, I have a listbox that should allow the user to select several
names and those names should be passed to the @People parameter. I can't
find a way to get that to work.

I can get a single name to work
(Me.CheckInTableAdapter.Fill(Me.dsClockIn.CheckIn,
lbPeople.SelectedValue.ToString, dtpStart.Value, dtpEnd.Value)).
Go to Google and type "sql server + passing arrays". You will find many
examples of what you are looking for.
Oct 14 '07 #4

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

Similar topics

1
by: yma | last post by:
Hi, I tried to use a listbox to display a column in MS Access 2000 nwind.mdb by using ole DataAdapter, Connection and dataset controls. But I got "It is already opened exclusively by another...
9
by: Nathan Sokalski | last post by:
I am trying to do a database search using LIKE using the following code: Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click If...
1
by: keith.walter | last post by:
My first asp.net app is almost "done" and I am stuck. Here is my situation: I have a "mother" page add_customer.aspx and a"child" user control add_group.ascx. On the mother page is an "add...
3
by: asadikhan | last post by:
Hi, I am trying to use a datalist to edit data in a MySql database as follows. For now I just want to be able to get the changes to be made on the dataset. Here is my code: using System;...
3
by: Paul | last post by:
I found a great site for CSS tempaltes, http://blog.html.it/layoutgala/ . I downloaded them, and played around with them. Then I tried to use the template in as ASP.Net MasterPage, but everything...
0
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.