Solved

Datatable Constraints

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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

11 Experts available now in Live!

Get 1:1 Help Now