コード例 #1
0
 public void Listar2()
 {
     if (D1.SelectedItem.ToString() == "Airbus")
     {
         SqlDataAdapter d    = new SqlDataAdapter("select Modelo from ModeloAIR", con);
         DataTable      data = new DataTable();
         d.Fill(data);
         D2.DataTextField  = "Modelo";
         D2.DataValueField = "Modelo";
         D2.DataSource     = data;
         D2.DataBind();
     }
     else if (D1.SelectedItem.ToString() == "Boeing")
     {
         SqlDataAdapter d    = new SqlDataAdapter("select Modelo from ModeloBO", con);
         DataTable      data = new DataTable();
         d.Fill(data);
         D2.DataTextField  = "Modelo";
         D2.DataValueField = "Modelo";
         D2.DataSource     = data;
         D2.DataBind();
     }
     else if (D1.SelectedItem.ToString() == "Embraer")
     {
         SqlDataAdapter d    = new SqlDataAdapter("select Modelo from ModeloEM", con);
         DataTable      data = new DataTable();
         d.Fill(data);
         D2.DataTextField  = "Modelo";
         D2.DataValueField = "Modelo";
         D2.DataSource     = data;
         D2.DataBind();
     }
 }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            con.Open();
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from Product where id= 17";
            cmd.ExecuteNonQuery();
            DataTable      dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            D2.DataSource = dt;
            D2.DataBind();
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            con.Open();

            SqlCommand cmd2 = con.CreateCommand();

            cmd2.CommandType = CommandType.Text;
            cmd2.CommandText = "select product_name,Username,Review from Product_Review where id=18";
            cmd2.ExecuteNonQuery();
            DataTable      dt1 = new DataTable();
            SqlDataAdapter da1 = new SqlDataAdapter(cmd2);

            da1.Fill(dt1);
            // D2.DataSource = dt1;
            D2.DataSource = null;
            D2.DataBind();

            con.Close();
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string connectionstring = WebConfigurationManager.ConnectionStrings["Unibook1ConnectionString"].ConnectionString;
            var    uname            = Context.User.Identity.Name;

            using (SqlConnection con = new SqlConnection(connectionstring))
            {
                SqlCommand com = new SqlCommand("Profile", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@useri", uname);


                con.Open();
                SqlDataAdapter adapter = new SqlDataAdapter(com);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);
                D2.DataSource = ds;
                D2.DataBind();
            }
        }