コード例 #1
0
ファイル: MiddleTier.cs プロジェクト: MuchDevelopment/RVVRB
        public RvvrbDataTable ReturnSong(int id)
        {
            if (sconn.State == ConnectionState.Closed)
            {
                try
                {
                    //open the connection
                    sconn.Open();

                    DataTable dt = new DataTable();
                    dt.TableName = "Songs";

                    scmd = new SqlCommand("getSongByID", sconn);
                    scmd.Connection = sconn;
                    scmd.CommandType = System.Data.CommandType.StoredProcedure;
                    scmd.Parameters.Add("@sid", SqlDbType.Int).Value = id;

                    SqlDataReader dr = scmd.ExecuteReader();
                    dt.Load(dr);
                    dr.Close();
                    RvvrbDataTable rdt = new RvvrbDataTable(dt);

                    return rdt;
                }
                catch (SqlException sqx)
                {
                    throw sqx;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    sconn.Close();
                    sconn.Dispose();
                    SqlConnection.ClearPool(sconn);
                }
            }
                return null;
        }
コード例 #2
0
ファイル: MiddleTier.cs プロジェクト: MuchDevelopment/RVVRB
        public RvvrbDataTable ReturnHomeSongs()
        {
            if (sconn.State == ConnectionState.Closed)
                {
                    try
                    {
                        //open the connection
                        sconn.Open();

                        DataTable dt = new DataTable();
                        dt.TableName = "Songs";

                        scmd = new SqlCommand("getAllSongsNotInPlaylists", sconn);
                        scmd.Connection = sconn;
                        scmd.CommandType = System.Data.CommandType.StoredProcedure;

                        SqlDataReader dr = scmd.ExecuteReader();
                        dt.Load(dr);
                        dr.Close();
                        RvvrbDataTable rdt = new RvvrbDataTable(dt);
                        return rdt;

                    }

                    catch (SqlException sqx)
                    {
                        throw sqx;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        sconn.Close();
                        sconn.Dispose();
                        SqlConnection.ClearPool(sconn);
                }
                }
                return null;
        }