Пример #1
0
        void Loaddata()
        {
            string        connStr = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            SqlConnection conn    = new SqlConnection(connStr);
            //string sql = "SELECT dvdid,title,description,actor,type,category,date FROM dvds dvd,casting cas,type tp, category ct where dvd.castingId=cas.id and dvd.typeid=tp.id and dvd.categoryid=ct.id";
            string            sql      = "select * from dvds";
            string            sql2     = "select * from category";
            string            sql3     = "select * from casting";
            string            sql4     = "select * from type";
            SqlDataAdapter    adapter  = new SqlDataAdapter(sql, conn);
            SqlDataAdapter    adapter1 = new SqlDataAdapter(sql2, conn);
            SqlDataAdapter    adapter2 = new SqlDataAdapter(sql3, conn);
            SqlDataAdapter    adapter3 = new SqlDataAdapter(sql4, conn);
            SqlCommandBuilder builder  = new SqlCommandBuilder(adapter);
            SqlCommandBuilder builder1 = new SqlCommandBuilder(adapter1);
            SqlCommandBuilder builder2 = new SqlCommandBuilder(adapter2);
            SqlCommandBuilder builder3 = new SqlCommandBuilder(adapter3);
            DataSet           ds       = new DataSet();
            DataSet           ds1      = new DataSet();
            DataSet           ds2      = new DataSet();
            DataSet           ds3      = new DataSet();

            adapter.Fill(ds, "dvd");
            adapter1.Fill(ds1, "category");
            adapter2.Fill(ds2, "casting");
            adapter3.Fill(ds3, "type");
            ds.Tables["dvd"].PrimaryKey       = new DataColumn[] { ds.Tables["dvd"].Columns["dvdid"] };
            ds1.Tables["category"].PrimaryKey = new DataColumn[] { ds1.Tables["category"].Columns["id"] };
            ds2.Tables["casting"].PrimaryKey  = new DataColumn[] { ds2.Tables["casting"].Columns["id"] };
            ds3.Tables["type"].PrimaryKey     = new DataColumn[] { ds3.Tables["type"].Columns["id"] };
            Cache["DATASET"]  = ds;
            Cache["DATASET1"] = ds1;
            Cache["DATASET2"] = ds2;
            Cache["DATASET3"] = ds3;
            Cache["ADAPTER"]  = adapter;
            Cache["ADAPTER1"] = adapter1;
            Cache["ADAPTER2"] = adapter2;
            Cache["ADAPTER3"] = adapter3;

            dvd.DataSource      = ds.Tables["dvd"];
            category.DataSource = ds1.Tables["category"];
            casting.DataSource  = ds2.Tables["casting"];
            type.DataSource     = ds3.Tables["type"];
            dvd.DataBind();
            category.DataBind();
            casting.DataBind();
            type.DataBind();
            DropDownListcat.DataSource     = ds1.Tables["category"];
            DropDownListcat.DataTextField  = "categorymv";
            DropDownListcat.DataValueField = "id";
            DropDownListcat.DataBind();
            DropDownListcast.DataSource     = ds2.Tables["casting"];
            DropDownListcast.DataTextField  = "actor";
            DropDownListcast.DataValueField = "id";
            DropDownListcast.DataBind();
            DropDownListtype.DataSource     = ds3.Tables["type"];
            DropDownListtype.DataTextField  = "typemv";
            DropDownListtype.DataValueField = "id";
            DropDownListtype.DataBind();
        }
Пример #2
0
        private void LoadFrmCache()
        {
            DataSet ds  = (DataSet)Cache["DATASET"];
            DataSet ds1 = (DataSet)Cache["DATASET1"];
            DataSet ds2 = (DataSet)Cache["DATASET2"];
            DataSet ds3 = (DataSet)Cache["DATASET3"];

            dvd.DataSource      = ds.Tables["dvd"];
            category.DataSource = ds1.Tables["category"];
            casting.DataSource  = ds2.Tables["casting"];
            type.DataSource     = ds3.Tables["type"];
            dvd.DataBind();
            category.DataBind();
            casting.DataBind();
            type.DataBind();
            DropDownListcat.DataSource     = ds1.Tables["category"];
            DropDownListcat.DataTextField  = "categorymv";
            DropDownListcat.DataValueField = "id";
            DropDownListcat.DataBind();
            DropDownListcast.DataSource     = ds2.Tables["casting"];
            DropDownListcast.DataTextField  = "actor";
            DropDownListcast.DataValueField = "id";
            DropDownListcast.DataBind();
            DropDownListtype.DataSource     = ds3.Tables["type"];
            DropDownListtype.DataTextField  = "typemv";
            DropDownListtype.DataValueField = "id";
            DropDownListtype.DataBind();
        }