Guest User

Untitled

a guest
Jun 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.73 KB | None | 0 0
  1.   public class SqlDataProduct
  2.     {
  3.         public string name { get; set; }
  4.         public string amount { get; set; }
  5.         public List<string> listGroup { get; set; }
  6.     }
  7.  
  8.        using (SqlConnection conn = new SqlConnection(m_connectionString))
  9.                 {
  10.                     conn.Open();
  11.                     using (SqlCommand queryProductResponse = new SqlCommand(queryProduct, conn))
  12.  
  13.                     {
  14.                         SqlDataReader reader = queryProductResponse.ExecuteReader();
  15.  
  16.                         if (reader.HasRows)
  17.                         {
  18.                             while (reader.Read())
  19.                             {
  20.                                 int adressId = 0;
  21.  
  22.                                 SqlDataProduct sqlData = new SqlDataProduct();
  23.  
  24.                    
  25.                                 sqlData.name = reader["Nazwa"].ToString();
  26.                                 sqlData.amount= reader["Amount"].ToString();
  27.                          
  28.                                 sqlData.listGroup = new List<string>();
  29.    
  30.                                 using (SqlCommand queryGroupResponse = new SqlCommand(queryGroup, conn))
  31.                                 {
  32.                                     SqlDataReader readerGroup = queryGroupResponse.ExecuteReader();
  33.                                     if (readerGroup.HasRows)
  34.                                     {//pobieranie struktury  kategori i ich id dla produktu
  35.                                         while (readerGroup.Read())
  36.                                         {
  37.                                            
  38.                                             sqlData.listGroup.Add(readerGroup["GN"].ToString());
  39.                                      
  40.                                      
  41.                                             using (SqlCommand queryGroupNameResponse = new SqlCommand(queryGroupName, conn))
  42.                                             {
  43.                                                 SqlDataReader readerGroupName = queryGroupNameResponse.ExecuteReader();
  44.                                                 if (readerGroupName.HasRows)
  45.                                                 {
  46.                                                     sqlData.listGroup.Add(readerGroupName["TwG_Nazwa"].ToString());
  47.                                                 }
  48.  
  49.                                                 else
  50.                                                 {
  51.                                                     break;  
  52.                                                 }
  53.                                             }
  54.                                         }
  55.                                     }
  56.                                 }
Advertisement
Add Comment
Please, Sign In to add comment