Solved

Datatable Constraints

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

816 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now