Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.OleDb;
- namespace Database
- {
- public partial class WebForm3 : System.Web.UI.Page
- {
- OleDbConnection DB; //= new OleDbConnection(ConnectionString);
- String NomeDataBase; // = @"App_Data//" + "Northwind.accdb";
- String PercorsoDateBase; // = HttpContext.Current.Server.MapPath(NomeDataBase);
- String ConnectionString; // = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + PercorsoDateBase + ";Persist Security Info=False;";
- protected void Page_Load(object sender, EventArgs e)
- {
- NomeDataBase = @"App_Data//" + "Northwind.accdb";
- PercorsoDateBase = HttpContext.Current.Server.MapPath(NomeDataBase);
- ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + PercorsoDateBase + ";Persist Security Info=False;";
- DB = new OleDbConnection(ConnectionString);
- if (!IsPostBack)
- {
- DB.Open();
- OleDbCommand cmd = new OleDbCommand();
- cmd.Connection = DB;
- cmd.CommandText = "SELECT IDCliente, NomeSocietà, Indirizzo FROM Clienti ORDER BY NomeSocietà";
- cmb.DataTextField = "NomeSocietà";
- cmb.DataValueField = "IDCliente";
- cmb.DataSource = cmd.ExecuteReader();
- cmb.DataBind();
- cmb.SelectedIndex = 0;
- //lbl.Text = cmb.SelectedValue;
- DB.Close();
- }
- visualizza();
- }
- void visualizza()
- {
- DB.Open();
- OleDbCommand cmd = new OleDbCommand();
- cmd.Connection = DB;
- cmd.CommandText = "SELECT IDOrdine, DataOrdine, Trasporto FROM Ordini WHERE IDCliente = '" + cmb.SelectedValue + "' ORDER BY DataOrdine ";
- DataSet ds = new DataSet();
- OleDbDataAdapter uno = new OleDbDataAdapter(cmd);
- uno.Fill(ds);
- GridView1.DataSource = ds.Tables[0];
- GridView1.DataBind();
- //lbl.Text = cmb.SelectedValue;
- DB.Close();
- }
- protected void cmb_SelectedIndexChanged(object sender, EventArgs e)
- {
- lbl.Text = cmb.SelectedValue;
- String NomeDataBase = @"App_Data//" + "Northwind.accdb";
- String PercorsoDateBase = HttpContext.Current.Server.MapPath(NomeDataBase);
- String ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + PercorsoDateBase + ";Persist Security Info=False;";
- OleDbConnection DB = new OleDbConnection(ConnectionString);
- DB.Open();
- OleDbCommand cmd = new OleDbCommand();
- cmd.Connection = DB;
- cmd.CommandText = "SELECT Ordini.IDOrdini";
- }
- //protected void cmb_SelectedIndexChanged(object sender, EventArgs e)
- //{
- // lbl.Text = cmb.SelectedValue;
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement