07-08-2013, 01:03 PM
hello,
i am coding a tool and i would like how to get records from a table.
i have been "googling" and i have found this structure:
SqlConnection sqlconn = 2 SqlConnection(connectionStr);
SqlCommand sqlcomm = 2 SqlCommand("SELECT * FROM OrderDetail", sqlconn);
SqlDataReader reader = sqlcomm.ExecuteReader();
const int UNITPRICE = 0;
const int QUANTITY = 1;
while (reader.Read())
{
float unitPrice = reader.getFloat(UNITPRICE);
int quantity = reader.getInt(QUANTITY);
// Do whatever with the values.
}
reader.Dispose();
sqlcomm.Dispose();
sqlconn.Dispose();
but i dont know if it works and of course, i wouldnt like to work on it and finally, it doesnt work. so i would like you could help me.
thanks in advance.
P.S. if there is another method easier than i have found, please tell me or if this method is good and i have to modify it tell me too please

