コード例 #1
0
ファイル: Profil.aspx.cs プロジェクト: edgeofstorm/SE_Project
    private void BindFav()
    {
        string conn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;

        using (SqlConnection con = new SqlConnection(conn))
        {
            using (SqlCommand cmd = new SqlCommand("select * from Bike WHERE OwnerID = '" + Convert.ToInt32(Session["KullaniciID"]) + "' ", con))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
                {
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    RepIlan.DataSource = dt;
                    RepIlan.DataBind();
                }
            }
        }
    }
コード例 #2
0
    private void BindIlan()
    {
        string conn = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

        using (SqlConnection con = new SqlConnection(conn))
        {
            using (SqlCommand cmd = new SqlCommand("SELECT dbo.Bike.BikeID, dbo.Bike.OwnerID, dbo.Bike.Brand, dbo.Bike.Category, dbo.Bike.Picture, dbo.Bike.Description, dbo.Bike.Transmission, dbo.Bike.AdsHeader, dbo.Bike.Price, dbo.Bike.Currency, dbo.Bike.AddingDate, dbo.Bike.Availability, dbo.Bike.BikeCity, dbo.Bike.BikeCounty, dbo.OnRentBike.RenterCheckIn, dbo.OnRentBike.HirerCheckIn FROM dbo.Bike LEFT OUTER JOIN dbo.OnRentBike ON dbo.Bike.BikeID = dbo.OnRentBike.BikeID WHERE(dbo.Bike.OwnerID = '" + Convert.ToInt32(Session["KullaniciID"]) + "') AND(dbo.Bike.Availability = '1')", con))
            {
                using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
                {
                    DataTable dt = new DataTable();
                    sda.Fill(dt);
                    Session.Add("IlanSayisi", dt.Rows.Count.ToString());
                    RepIlan.DataSource = dt;
                    RepIlan.DataBind();
                    if (dt.Rows.Count == 0)
                    {
                        RepIlan.Visible  = false;
                        zeroIlan.Visible = true;
                    }
                }
            }
        }
    }