protected void SearchCarteButton_Click(object sender, EventArgs e) { string constr = ConfigurationManager.ConnectionStrings["EngineDatabase"].ConnectionString; SqlConnection con = new SqlConnection(constr); string comm = "SELECT IdCarte, IdEditura, Titlu, Autor, DataPublicare, Categorie, ExemplareVandute FROM [Carte] WHERE ExemplareVandute >= @min_value AND ExemplareVandute <= @max_value"; SqlCommand cmd = new SqlCommand(comm); try { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; sda.SelectCommand.Parameters.AddWithValue("@min_value", SearchMinValue.Text); sda.SelectCommand.Parameters.AddWithValue("@max_value", SearchMaxValue.Text); using (DataTable dt = new DataTable()) { sda.Fill(dt); SearchedItemsDetailsView.DataSource = dt; SearchedItemsDetailsView.DataBind(); } } } catch (Exception ex) { LabelSearchStatus.Text = "Failed"; } }
private void BindDetailsView() { string constr = ConfigurationManager.ConnectionStrings["EngineDatabase"].ConnectionString; SqlConnection con = new SqlConnection(constr); string comm = "SELECT IdCarte, IdEditura, Titlu, Autor, DataPublicare, Categorie, ExemplareVandute FROM [Carte]"; SqlCommand cmd = new SqlCommand(comm); try { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); SearchedItemsDetailsView.DataSource = dt; SearchedItemsDetailsView.DataBind(); } } } catch (Exception ex) { } }