Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ToString());
  2. conn.Open();
  3. var da = new SqlDataAdapter("Select Product_Category from Product
  4. where
  5. Product_Id =" + fo, conn);
  6. da.Fill(mydata);
  7. conn.Close();
  8.  
  9. string Product_Category = String.Empty;
  10. if(mydata.Rows.Count>0)
  11. {
  12. Product_Category = mydata.Rows[0]["Product_Category"].ToString();
  13. }
  14.  
  15. DataTable results = MyMethod.GetResults(); // i am getting data from getresult function
  16. if(results != null && results.Rows.Count > 0) // Check datatable is null or not
  17. {
  18. List<string> lstring = new List<string>();
  19. foreach(DataRow dataRow in dt.Rows)
  20. {
  21. lstring.Add(Convert.ToString(dataRow["ColumnName"]));
  22. }
  23. string mainresult = string.Join(",", lstring.ToArray()); // You can Use comma(,) or anything which you want. who connect the two string. You may leave space also.
  24. }
  25. Console.WriteLine (mainresult);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement