Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. [WebMethod]
  2. public List<clsVFCustomer> GetVFCustomerList()
  3. {
  4. List<clsVFCustomer> lstVFCust = new List<clsVFCustomer>();
  5. SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["connString"].ToString());
  6. DataTable dt = new DataTable();
  7. SqlCommand command = new SqlCommand("SELECT * FROM VFCustomer", conn);
  8. command.CommandType = CommandType.Text;
  9. command.CommandTimeout = 0;
  10. SqlDataAdapter sda = new SqlDataAdapter(command);
  11. conn.Open();
  12. sda.Fill(dt);
  13. conn.Close();
  14. dt.TableName = "dt";
  15. if (dt.Rows.Count > 0)
  16. {
  17. for (int idx = 0; idx < dt.Rows.Count; idx++)
  18. {
  19. clsVFCustomer vfCust = new clsVFCustomer();
  20. vfCust.Name = dt.Rows[idx]["Name"].ToString();
  21. vfCust.Address = dt.Rows[idx]["Address"].ToString();
  22. vfCust.ContactNo = dt.Rows[idx]["ContactNo"].ToString();
  23. vfCust.Email = dt.Rows[idx]["Email"].ToString();
  24. lstVFCust.Add(vfCust);
  25. }
  26. }
  27. return lstVFCust;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement