Solved

Datatable Constraints

Posted on 2014-10-27
4
102 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 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