Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I also would use a Typed DataSet or create your own class that holds the properties so you are not dealing with strings like <code>row["Address"]</code> you would say <code>object.Address</code> and get compile time checking.</p> <p>DataSets have a lot of built in functionality that is nice but also caries with it a lot of overhead that might not be needed in something simple. Creating a simple class with properties and passing that out of your data access layer is probably the simplest way to implement what you want.</p> <p><strong>Something like this on the DAL (Data Access Layer) side</strong>:</p> <pre><code>//Also pass in the blogID dont have the DAL get the value from the UI layer.. //make the UI layer pass it in. public IList&lt;Supplier&gt; GetSuppliers(string connectionString, int blogID) { IList&lt;Supplier&gt; suppliers = new List&lt;Supplier&gt;(); //wrap with the using statements using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand("con_spSuppliersList", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@blogid", blogID); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { suppliers.Add(new Supplier { Address = reader.GetString(0), Telephone = reader.GetString(1) }); } } } return suppliers; } } public class Supplier { //I would have Address an object....but you have as string //public Address Address { get; set; } public string Address { get; set; } public string Telephone { get; set; } } //Example if you went with Address class... public class Address { //Whatever you want in the address public string StreetName { get; set; } public string Country { get; set; } public string Region { get; set; } public string City { get; set; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload