Solved

Datatable Constraints

Posted on 2014-10-27
4
100 Views
Last Modified: 2014-11-24
OK, so I need to fill a datatable from my dataset...but I keep getting Constraints due to my primary key.
It works fine if I run it in the DataSet window...why I can't I fill an empty datatable with this information?

See screen shots!

        Dim ClientList As New RPS_EIPDataSetTableAdapters.tbl_ClientListTableAdapter
        Dim ClientListTable As New DataTable
Preview Data        This is when I get the error:
        ClientListTable = ClientList.GetDataBy_ClientID(CType(cb_ClientList.SelectedValue, Int32))


Thanks,
Mark
0
Comment
Question by:smithmrk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 40411247
Is your primary key set on ClientNum column? That column has duplicate values so error is understandable.
0
 

Author Comment

by:smithmrk
ID: 40413278
Yes, but how can I put the information from the database into a BLANK DataTable that doesn't have any primary keys?
I don't want to take the primary key off my real database...I just want to put the results of the query into a BLANK Database with NO Constraints.

Mark
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 40453693
The reason you get this error is that the method call is returning a typed datatable. That typed data table has all the constraints configured same as in database. The fact that you are assigning the result to an untyped datatable does not help as the function still has to populate and return a typed datatable.

Solution would be to either change the query so that it does not return duplicates or to use a separate method which does not use the typed datatable.
0
 

Author Closing Comment

by:smithmrk
ID: 40463039
OK, Thanks!

Mark
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
get combo value in class 5 24
ASP.NET (VB) return a record 2 52
VB.NET System.NullReferenceException 1 27
Broken .resx file generating errors 18 27
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question