List<Order> orders = new List<Order>();
using (SqlConnection connection = new SqlConnection("Server: 192.168..."))
{
conn.Open();
using (SqlCommand command = connection.CreateCommand()){
command.CommandText = "sp_GetOrders";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@UserID", userID);
using(SqlDataReader = reader = command.ExecuteReader()){
while(reader.Read()){
Order newOrder = new Order();
newOrder.ID = Convert.ToInt32(reader["Id"]);
newOrder.Name = reader["Name"].ToString();
orders.Add(newOrder);
}
}
}
}