Note that there are some explanatory texts on larger screens.

plurals
  1. POXSD DataSets and ignoring foreign keys
    text
    copied!<p>I have a pretty standard table set-up in a current application using the <a href="https://en.wikipedia.org/wiki/.NET_Framework" rel="nofollow noreferrer">.NET</a> <a href="https://en.wikipedia.org/wiki/XML_Schema_%28W3C%29" rel="nofollow noreferrer">XSD</a> <code>DataSet</code> and <code>TableAdapter</code> features. My <code>contracts</code> table consists of some standard contract information, with a column for the <code>primary department</code>. This column is a <a href="https://en.wikipedia.org/wiki/Foreign_key" rel="nofollow noreferrer">foreign key</a> to my <code>Departments</code> table, where I store the basic <code>department name</code>, <code>id</code>, <code>notes</code>. This is all setup and functioning in my <a href="https://en.wikipedia.org/wiki/Microsoft_SQL_Server" rel="nofollow noreferrer">SQL Server</a>.</p> <p>When I use the XSD tool, I can drag both tables in at once and it auto detects/creates the foreign key I have between these two tables. This works great when I'm on my main page and am viewing contract data.</p> <p>However, when I go to my administrative page to modify the department data. I typically do something like this:</p> <pre><code>Dim dtDepartment As New DepartmentDataTable() Dim taDepartment As New DepartmentTableAdapter() taDepartment.Fill(dtDepartment) </code></pre> <p>However, at this point an exception is thrown saying to the effect that there is a foreign key reference broken here, I'm guessing since I don't have the <code>Contract</code> <code>DataTable</code> filled.</p> <p>How can I fix this problem? I know I can simply remove the foreign key from the XSD to make things work fine, but having the additional integrity check there and having the XSD schema match the SQL schema in the database is nice.</p>
 

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