TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
RD Design
NA
25
26.7k
How to pass value from string array to Select statement?
Feb 23 2015 5:34 AM
Hi,
I have a List and there I have stored customerNo from database like this
List<string[]> _customerDetails = new List<string[]>();
while (readerCus.Read())
{
string[] fields = new string[2];
fields[0] = readerCus["Customer"].ToString();
_customerDetails.Add(fields);
}
Inside a foreach I need to get this "Customer" no one by one and pass it to SQL select statement.
foreach (string[] fields in _customerDetails)
{
string cusId = fields[0];
using (SqlConnection con2 = new SqlConnection(connectionString))
{
con2.Open();
using (SqlCommand command2 = new SqlCommand("SELECT * FROM dbo.Customers WHERE Customer = '" + fields[0].ToString() + "'", con2))
using (SqlDataReader reader2 = command2.ExecuteReader())
{
while (reader2.Read())
{
//My code and here I am generating a token for customer
}
}
}
}
My issue is all the time it runs one time and generate a token.Not continuing and not completing all available customers (say 1000 customers).Any one can point me how can I loop through all customers one by one.
Thank
Reply
Answers (
3
)
Code for send sms is not working
How to binddata to grid or dropdown from oracledatareader