Hello everyone, i am having this issue, i have a table in ms sql server database called customer,
and i am doing a select statement like: select top 5 customername, customeraddress, customerPhone, dateOfPurchase
from customer order by dateOfPurchase ASC in a stored procedure. and in my C# code i am using
datareader to retrive the records.
while (rdr.Read())
{
customername = rdr["customername"].ToString();
customeraddress = rdr["customeraddress"].ToString();
customerPhone = rdr["customerPhone"].ToString();
dateOfPurchase = rdr["dateOfPurchase"].ToString();
}
the above code is returning only the last record, i want to be able to store each of the customer record
in a variable. i.e.
while (rdr.Read())
{
//customer#1
string customer_1_Name= rdr["customername"].ToString();
string customer_1_customeraddress= rdr["customeraddress"].ToString();
string customer_1_customerPhone=rdr["customerPhone"].ToString();
string customer_1_dateOfPurchase = rdr["dateOfPurchase"].ToString();
//customer#2
string customer_2_Name= rdr["customername"].ToString();
string customer_2_customeraddress= rdr["customeraddress"].ToString();
string customer_2_customerPhone=rdr["customerPhone"].ToString();
string customer_2_dateOfPurchase = rdr["dateOfPurchase"].ToString();
//etc
}
Please assist, thanks in advance...