Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I populate the data from my Stored Procedure into my winform?
    primarykey
    data
    text
    <p>I'm pretty new to programming and have run into a problem with a basic application I am working on. I have a person class which resembles this...</p> <pre><code> Person { SqlConnection conn = new SqlConnection(@"Integrated Security=True; Data Source=ME\MyPRESS;Initial Catalog=TEST5"); SqlCommand cmd = new SqlCommand("usp_employee", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@emp_id", SqlDbType.Int).Value = id; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) try { conn.Open(); { department = dr["dept_name"].ToString(); fname = dr["emp_first_name"].ToString(); lname = dr["emp_last_name"].ToString(); email = dr["emp_email"].ToString(); phone = dr["emp_phone"].ToString(); position = dr["emp_position"].ToString(); address1 = dr["emp_address1"].ToString(); address2 = dr["emp_address2"].ToString(); city = dr["emp_city"].ToString(); state = dr["emp_state"].ToString(); postal_code = dr["emp_postal_code"].ToString(); // department = txtFirst_name.Text; } } finally { // 3. close the reader if (dr != null) { dr.Close(); } // close the connection if (conn != null) { conn.Close(); } } } </code></pre> <p>protected string department;</p> <pre><code> public string Department { get { return department; } set { department = value; } } protected string fname; public string Fname { get { return fname; } set { fname = value;} } protected string lname; public string Lname { get { return lname; } set { lname = value; } } protected string email; public string Email { get { return email; } set { email = value; } } protected string position; public string Position { get { return position; } set { position = value; } } protected string address1; public string Address1 { get { return address1; } set { address1 = value; } } protected string address2; public string Address2 { get { return address2; } set { address2 = value; } } protected string phone; public string Phone { get { return phone; } set { phone = value; } } protected string city; public string City { get { return city; } set { city = value; } } protected string state; public string State { get { return state; } set { state = value; } } protected string postal_code; public string Postal_Code { get { return postal_code; } set { postal_code = value; } } </code></pre> <p>}</p> <p>I have a form and a db with a stored procedure to retrieve the data as you can see above.... Where I am lost is in wiring up my form to display the record from the stored procedure.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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