c# - Comparing dataSet values -
I am using this code to display images to edit:
< Code> safe void repeiter_Outer_ItemDataBound (object sender, repeater item avent e) {repeater item = E. ITEM; If (item item type == list item type.itm). Type item.im Type == List item. Aborting item) {repeater inner = (repeater) item. Fund control ("image_reptiter"); Hiddenfield Inner_ID = (hidden field) items Fund control ("hidden field_id"); MySqlConnection conn = New MySqlConnection (Configuration Manager. Connection Strings ["DBCNX"]. Toasting ()); MySqlCommand cmdNew = New MySqlCommand (); CmdNew.Connection = conn; CmdNew.Parameters.AddWithValue ("@ ID", Inner_ID.value); CmdNew.CommandText = "Select from images WHERE FK_album = @id"; Conn.Open (); Inner.DataSource = cmdNew.ExecuteReader (); Inner.DataBind (); Label_Amount = Label (label) item.FindControl ("Label_Amount"); Label_Amount.Text = Convert Toaster (inner.itimes.cc); Conn.Close (); }}
My problem is that every time the offender runs it, it connects to the database, which takes a very long time to load the page (such as 10 seconds) then I A general list of databases or databases, instead of trying to do it:
secure static list & lt; String & gt; DataSetImages () {MySqlConnection conn = New MySqlConnection (Configuration Manager. Connection Strings ["DBCNX"] .toasting ()); String sql = "select * from images"; MySqlCommand CMD = New MySqlCommand (SQL, conn); Conn.Open (); MySqlDataAdapter sqlDataAdapter = New MySqlDataAdapter (CMD); Dataset dataset = new dataset (); SqlDataAdapter.Fill (dataset); Conn.Close (); & Lt; String & gt; ImageList = new list & lt; String & gt; (); (Int i = 0; i & lt; = Dataset Tables [0] .Rows.Count - 1; i ++) {string id = dataSet.Tables [0] .rove [i] .may [0]. Ostring (); String img_name = dataset tabs [0] .rove [i] .imrah [1]. Ostring (); String img_alt = DataSet.Tables [0] .ows [i] .mother [2] .ostring (); String FK_album = DataSet.Tables [0] .rove [i] .mother [3] .restring (); ImageList.Add (ID); ImageList.Add (img_name); ImageList.Add (img_alt); ImageList.Add (FK_album); } Back to the image list; }
How can I use it and compare FK_album to Inner_Id.Value?
If you are requesting to use, then this is what your Are looking for
string expression = string.format ("FK_album = {0}", Inner_Id.Value); Datarov [] Filter Line = Image List. Tables [0]. Select (expression);
Here's an article.
Comments
Post a Comment