473,396 Members | 2,018 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,396 software developers and data experts.

Using List<T> elements as variable in query

I am trying to query an Informix database using a List<T> collection's elements as variables. I can build the list and connect to the database, but I am unsure how to iterate through the list and query the database for each item in the collection.

My list is of type string, and contains Order Numbers. I want to query item information for each order number in the list.

I hope this is enough information. Thank you for your help.

Wes
Aug 27 '14 #1
1 1319
This is what I have so far.... As I'm sure you can probably tell, I am just trying to feel my way through this. I have only been coding in C# for a couple of weeks.

Expand|Select|Wrap|Line Numbers
  1.  
  2. List<string> orders = new List<string>();
  3.  
  4.             foreach (DataGridViewRow dr in ordersTable.Rows)
  5.             {
  6.                 orders.Add(dr.Cells["szPOSOrderNumber"].Value.ToString());
  7.             }
  8.  
  9. IfxCommand cmd = new IfxCommand("SELECT item_code, item_description FROM ioq_hdr WHERE ioqh_nbr = @orderNumber", conn);
  10.  
  11.  
  12.             for (int i = 0; i < orders.Count(); i++)
  13.             {
  14.                 Item orderItem = new Item();
  15.  
  16.                 int ioqh_nbr = int.Parse(orders.ElementAt(i));
  17.  
  18.                 cmd.ExecuteReader();
  19.  
  20.                 orderItem.itemCode = "ABC123";
  21.  
  22.             }
Aug 27 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

50
by: Steve | last post by:
How do you rewrite the swap function without using a tmp variable in the swap function???? int main() { int x = 3; int y = 5; // Passing by reference
0
by: shumaker | last post by:
I can't find the syntax for using a global variable. I have already added the global variable and set a default variable in the package properties. I have a Process Execution Task and would like...
8
by: Bri | last post by:
Greetings, I am using Eval() in a query with only limited success. If the text within the function contains a reference to a Field I get #ERROR#. I'll try and explain what I'm trying to do and...
6
by: msigwald | last post by:
The following line of code works, however, since my professor is a real purist of c, I would like to know if this code is valid (is it good code or a piece of crap?): #define DMP_FILE argv ...
4
by: Ramez | last post by:
Hi I need to create an object of a class using a type variable. for example, instead of writing: X = new MyClass I want to write something like: Dim t as Type = GetType(MyClass) X =...
8
by: Michael | last post by:
Hi, I think my problem deals with class casting and inheritance. I want to deal with various Audio Formats, reading into memory for modification, working with it (done by different classes),...
11
by: DP | last post by:
hi, i have a films table and form. i have a txt field in teh form called txtSearch , and i;ve created a query with all the film table fields in it. how can i get the query to load up, wth the...
4
by: nirjhar.oberoi | last post by:
Hi, This is my first post on this group! i am beginner lever C programmer. I am trying to add two numbers or multiply them using a single variable! Your are not allowed to use Unions or any...
2
by: jobooker | last post by:
I'm having issues sorting. The short description is, how do I set the select attribute of xsl:sort to be the value of an xsl:variable? The longer description follows: What I want to do is to be...
0
by: bala venkata siva ram kum | last post by:
hi I want autocompletetextview in android here we are using sqlite database with query using cursor. public void cal() { SQLiteDatabase db= null; String TableName = "enquiryhead"; db...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.