Component Page /Country.cs (C#)
1: using System;  
2: using System.Collections.Generic;  
3: using Microsoft.ApplicationBlocks.Data;  
4: using System.Data.SqlClient;  
5: using System.Data;  
6:   
7: namespace QuizNetOnline.Logic  
8: {  
9:     [Serializable]  
10:     public class Country : ICountry  
11:     {  
12:         public string CountryCode { get; set; }  
13:         public string CountryDesc { get; set; }  
14:         public string CountryChar { get; set; }  
15:   
16:         public List<Country> GetCountries(ISqlWrapper iSqlWrapper)  
17:         {  
18:             List<Country> countries = new List<Country>();  
19:   
20:             string connStr = iSqlWrapper.GetConnectionString();  
21:   
22:             if (connStr == null)  
23:                 throw new NotImplementedException();  
24:   
25:             var parameters = new SqlParameter[2];  
26:   
27:             const string sproc = "GetCountry";  
28:   
29:             try  
30:             {  
31:                 DataTable tbl=iSqlWrapper.ExecuteDataset(connStr, CommandType.StoredProcedure, sproc, parameters).Tables[0];  
32:                 foreach (DataRow row in tbl.Rows)  
33:                 {  
34:                     Country country=new Country();  
35:                     country.CountryChar=row["CountryChar"].ToString();  
36:                     country.CountryDesc=row["CountryDesc"].ToString();  
37:                     country.CountryCode=row["CountryCode"].ToString();  
38:                     countries.Add(country);  
39:                 }  
40:   
41:                 return countries;  
42:             }  
43:             catch (Exception ex)  
44:             {  
45:                 ErrorLog errorLog = new ErrorLog();  
46:                 errorLog.LogException("SqlUpdateQuestionLog", ex, iSqlWrapper);  
47:                 throw;  
48:             }  
49:         }  
50:     }  
51: }  

.NET Documentation Tool is © 2002 - 2009 Winnersh Triangle Web Solutions Limited.