Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Assuming you have everything wired up correctly with your project reference to the dll and a using statement in your code file. </p> <pre><code>BugReports reader = new BugReports(); </code></pre> <p>That line only gets an instance of your <code>BugReports</code> class, in order to make it do some work you need to call your method. </p> <pre><code>reader.userRoleDropDown(); </code></pre> <p>I'm not sure why you are returning the <code>SqlDataReader reader</code> that you've already closed, it is no longer any use. Also you are selecting data by calling <code>reader = userRoleComm.ExecuteReader();</code> but all the work is commented out, not sure if that is intentional. </p> <p>Edit: </p> <p>You may be better off using a SQLDataAdapter since your UI controls won't be visible to your class, and you can't access the data in the SQLDataReader after it's closed.</p> <pre><code>public DataSet userRoleDropDown() { string connectionSrting = ConfigurationManager.ConnectionStrings["BugReports"].ConnectionString; string queryString = "SELECT UserRoleID, UserRoleName FROM userRoles"; using (SqlConnection connection = new SqlConnection(connectionSrting)) { SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = new SqlCommand( queryString, connection); adapter.Fill(dataset); return dataset; } } </code></pre> <p>Then you can do what ever you like with the selected data from your application. </p> <p>More info on the important classes used here: <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.aspx" rel="nofollow">SqlDataAdapter</a> <a href="http://msdn.microsoft.com/en-us/library/system.data.dataset.aspx" rel="nofollow">DataSet</a></p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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