コード例 #1
0
ファイル: T1ES1.svc.cs プロジェクト: glebsts/esi2011
 public AreaData[] Backend_GetAreas()
 {
     Trace.WriteLine("Backend_GetAreas");
     AreaData[] result = new AreaData[0];
     DataManager dataMan = new DataManager();
     result = dataMan.GetAreas();
     return result;
 }
コード例 #2
0
ファイル: DataManager.cs プロジェクト: glebsts/esi2011
        internal AreaData[] GetAreas()
        {
            List<AreaData> result = new List<AreaData>();
            try
            {
                using (SqlConnection dbConn = new SqlConnection(connectionString))
                {
                    string qsGetAreas = @"SELECT [ID], [NAME], [NETWORK_OWNER]  FROM [AREA]";
                    SqlCommand dbCommand = new SqlCommand(qsGetAreas, dbConn);

                    dbConn.Open();

                    SqlDataReader dbReader = dbCommand.ExecuteReader();

                    while (dbReader.Read())
                    {
                        try
                        {
                            AreaData ad = new AreaData();
                            ad.Id = dbReader.GetInt64(0);
                            ad.Name = String.Format("{0} ({1})", dbReader.GetString(1), dbReader.GetString(2));
                            result.Add(ad);

                        }
                        catch (Exception rowExc)
                        {
                            Debug.WriteLine("Error reading area row: " + rowExc.Message);
                        }
                    }
                    dbReader.Close();
                    dbCommand.Connection.Close();

                }
            }
            catch (Exception areaDataExc)
            {
                Debug.WriteLine("Error getting areas: " + areaDataExc.Message);
            }

            return result.ToArray();
        }