Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET - Is there a way to programmatically fill all tables in a strongly-typed dataset?
    primarykey
    data
    text
    <p>I have a SQL Server database for which I have created a strongly-typed DataSet (using the DataSet Designer in Visual Studio 2008), so all the adapters and select commands and whatnot were created for me by the wizard. </p> <p>It's a small database with largely static data, so I would like to pull the contents of this DB in its entirety into my application at startup, and then grab individual pieces of data as needed using LINQ. Rather than hard-code each adapter Fill call, I would like to see if there is a way to automate this (possibly via Reflection). </p> <p>So, instead of:</p> <pre><code>Dim _ds As New dsTest dsTestTableAdapters.Table1TableAdapter.Fill(_ds.Table1) dsTestTableAdapters.Table2TableAdapter.Fill(_ds.Table2) &lt;etc etc etc&gt; </code></pre> <p>I would prefer to do something like:</p> <pre><code>Dim _ds As New dsTest For Each tableName As String In _ds.Tables Dim adapter as Object = &lt;routine to grab adapter associated with the table&gt; adapter.Fill(tableName) Next </code></pre> <p>Is that even <strong>remotely</strong> doable? I have done a fair amount of searching, and I wouldn't think this would be an uncommon request, but I must be either asking the wrong question, or I'm just weird to want to do this. </p> <p>I will admit that I usually prefer to use unbound controls and not go with strongly-typed datasets (I prefer to write SQL directly), but my company wants to go this route, so I'm researching it. I think the idea is that as tables are added, we can just refresh the DataSet using the Designer in Visual Studio and not have to make too many underlying DB code changes.</p> <p>Any help at all would be most appreciated. Thanks in advance!</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