c# - Retrieving an element from a created list -


I created a list called 'PTNList', and whatever I needed was just properly added . Now I am trying to write code to get every list from that list and run it against the SQL query. I'm feeling a bit I'm not sure about how this really is about The CompareNumbers.txt file generates, but nothing is printed for it using

  (filestream FS = new filestream ("C: / temporary)" /CompareNumbers.txt ", FileMode.Append, FileAccess.Write)) using (StreamWriter SW = new streamers (FS)) foreach (various Pitian in Pitianelais) {// variables as user of SQL to count using "Ptn" / / Call with SQL / query with call DB; write it in a file; Nsolkprkash CMD line ( "Running Kviri"); String query 2 = @ "SELECT COUNT (PRODUCT_TYPE_NO) AS NumberOfProducts dbo.PRODUCT where PRODUCT_TYPE_NO =" + ptn; SqlCommand cmd2 = new SqlCommand (query2); 2. Connection = Con; Rdr = cmd2.ExecuteReader (); while (rdr.Read ()) {sw.WriteLine (rdr [ "NumberOfProducts"]);} Rdr.Close ();}  
< P>

You have not used apostrophes around values, but you should use the parameters anyway. You can use the query. For example, with this approach:

  string sql = @ "SELECT COUNT (PRODUCT_TYPE_NO) AS NumberOfProducts dbo.PRODUCT where PRODUCT_TYPE_NO IN ({0});"; String [] paramNames = PTNList.Select ((s, i) => "@ type" + i.ToString ()) .oir (); String inClause = string.Join (",", nickname); (SqlCommand cmd = new SqlCommand (string.Format (using sql, inClause)) {for (int i = 0; i & lt; paramNames.Length; i ++) {cmd.Parameters.AddWithValue (paramNames [i ], PTNList [i]);} // con.Open (); // if not already open Int Nanbrof Products = (Int) Simdi.aksekyuslarl ();}  

Update : You really want to just loop and count them, so you do not need this complex approach. UL-parameter must use and other issues such as Appropshs etc.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -