Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The fastest approach is to extend the autogenerated <code>TableAdapter</code> in your <code>DataSet</code> with a method that returns your ID's as <code>List&lt;int&gt;</code>.</p> <p>If you want to extend the functionality you can't change the generated classes in the DatesetName.designer.cs/vb (it will be recreated on any change) but the file without designer in its name(create it if it not exists). Then you have to extend the partial TableAdapter-class(in your case <code>menu_widac_wszystkoTableAdapter</code>).</p> <p>Have a look at following code to see what i mean, i haven't tested it but i hope you take my point:</p> <pre><code>namespace YourRootNameSpace.DataSet1TableAdapters { { public partial class menu_widac_wszystkoTableAdapter { public List&lt;int&gt; GetIdList(int categoryID) { List&lt;int&gt; list = new List&lt;int&gt;(); System.Data.SqlClient.SqlCommand command = this.CommandCollection[0]; command.CommandTimeout = command.Connection.ConnectionTimeout; System.Data.ConnectionState previousConnectionState = command.Connection.State; try { if (((command.Connection.State &amp; System.Data.ConnectionState.Open) != System.Data.ConnectionState.Open)) { command.Connection.Open(); } command.Parameters[ "@id" ].Value = categoryID; using (System.Data.SqlClient.SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { list.Add(reader.GetInt32(0)); } } } finally { if ((previousConnectionState == System.Data.ConnectionState.Closed)) { command.Connection.Close(); } } return list; } } } </code></pre> <p><strong>Edit</strong>: After i've read your edited question i saw that i've misunderstood your requirement a little bit, but my approach should be perfect anyway. Basically you don't want to get a <code>DataTable</code> but a <code>List&lt;int&gt;</code> with your product_ids.</p> <p>After you've extended the <code>TableAdapter</code> in the abovementioned way:</p> <pre><code>var da = new DataSet1TableAdapters.menu_widac_wszystkoTableAdapter(); List&lt;int&gt; productIDs = da.GetIdList(); </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.
 

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