Solved

Datatable Constraints

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

25 Experts available now in Live!

Get 1:1 Help Now