コード例 #1
0
        public PartyResults GetPartyByName(string name, string baseUrl)
        {
            DataSet       ds = new DataSet();
            SqlConnection cn = Connect();

            try
            {
                using (SqlCommand cmd = new SqlCommand("GetPartyByName", cn))
                {
                    cmd.Parameters.AddWithValue("@Name", name);
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        da.Fill(ds);
                    }
                }

                PartyResults pr = new PartyResults();

                DataTable t = FirstTable(ds);

                if (t == null)
                {
                    return(pr);
                }

                foreach (DataRow r in t.Rows)
                {
                    int    id        = Convert.ToInt32(r["id"]);
                    string type      = Convert.ToString(r["type"]);
                    string partyName = Convert.ToString(r["name"]);
                    string link      = string.Format("{0}party/{1}", baseUrl, id);

                    PartySummary ps = new PartySummary(id, type, partyName, link);
                    pr.PartyList.Add(ps);
                }

                return(pr);
            }

            finally
            {
                Disconnect(cn);
            }
        }
コード例 #2
0
        public PartyResults GetPartyByName(string name, string baseUrl)
        {
            DataSet ds = new DataSet();
            SqlConnection cn = Connect();
            try
            {

                using (SqlCommand cmd = new SqlCommand("GetPartyByName", cn))
                {
                    cmd.Parameters.AddWithValue("@Name", name);
                    cmd.CommandType = CommandType.StoredProcedure;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        da.Fill(ds);
                    }
                }

                PartyResults pr = new PartyResults();

                DataTable t = FirstTable(ds);

                if (t == null) { return pr; }

                foreach (DataRow r in t.Rows)
                {
                    int id = Convert.ToInt32(r["id"]);
                    string type = Convert.ToString(r["type"]);
                    string partyName = Convert.ToString(r["name"]);
                    string link = string.Format("{0}party/{1}", baseUrl, id);

                    PartySummary ps = new PartySummary(id, type, partyName, link);
                    pr.PartyList.Add(ps);
                }

                return pr;

            }

            finally
            {
                Disconnect(cn);
            }
        }