Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-03-2003, 02:00 PM   #1
Member (6 bit)
 
Join Date: Oct 2002
Posts: 55
Question "Failed to enable constraints. One or more rows contain values violating non-null, un

"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." string





Hi!

I get this error when I excetute this code

(error on line: m_dataAdapter.Fill(m_dsCarTrade,"CustomerAddress")


also I get one error in one Row:



(Tables have a relationship to eachother)


Code:
		private OleDbDataAdapter m_dataAdapter;

		private OleDbConnection m_accessConnection;

		private OleDbCommand m_accessCommand;


		private	const string m_conStrAccessConnection  = "provider=Microsoft.JET.OLEDB.4.0; " + 
													   "data source = C:\\Visual Studio Projects\\" +
													   "CarTrade\\CarTradeDB.mdb";	

                private const string m_conStrSelectCommandCustomer = "SELECT Customer.*, CustomerAddress.* FROM Customer INNER JOIN CustomerAddress ON Customer.CustomerID = CustomerAddress.CustomerID";


		private void LoadFreshCustomersFromDB()
		{
			//we create an access object
			m_accessConnection = new OleDbConnection(m_conStrAccessConnection);
			m_accessCommand = new OleDbCommand(m_conStrSelectCommandCustomer, m_accessConnection);
			m_dataAdapter = new OleDbDataAdapter(m_accessCommand);

			//we open the connection to DB
			m_accessConnection.Open();

			try
			{
				m_dataAdapter.Fill(m_dsCarTrade,"CustomerAddress");

				m_dataAdapter.Fill(m_dsCarTrade,"Customer");

			}
			catch (Exception e)
			{
				MessageBox.Show("Sorry....but we have some problems with database. " + "Error message from database : " + e.Message,"ERROR!!!");

			}
			finally
			{
				//we close the connection to DB
				m_accessConnection.Close();
			}

			m_dtCustomers = m_dsCarTrade.Tables["Customer"];
		}
Know someone why this error caused?



gicio
gicio is offline   Reply With Quote
Old 03-03-2003, 10:26 PM   #2
Member (12 bit)
 
Paul Victorey's Avatar
 
Join Date: Mar 1999
Location: MN or WI
Posts: 3,017
This is Java?

Can you provide the information about OleDbDataAdapter.Fill()?
Paul Victorey is offline   Reply With Quote
Old 03-04-2003, 08:16 AM   #3
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
This is C++, right?

I found this as a possible solution:

"1) "Failed to enable constraints" usually means there are constraints in
your DataSet that your database tables don't satisfy. First, try removing
all your DataSet constraints."

I can't seem to find where you initialize m_dsCarTrade, so I am assuming you initialize it elsewhere. Try setting m_dsCarTrade.EnforceConstraints=False.
doctorgonzo is offline   Reply With Quote
Old 03-04-2003, 08:26 AM   #4
Member (6 bit)
 
Join Date: Oct 2002
Posts: 55
it's C#



gicio
gicio is offline   Reply With Quote
Old 03-06-2003, 03:29 AM   #5
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
I was really puzzled when reading your code, it uses const so it's not Java, but everything else (private location, exception handling ...) looks like Java!
Any way, I'm sorry I don't know C#, so I can help.
aym is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:30 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2