Remortgages | Car Finance | Internet Advertising | Property in Spain | The eBay Song
"Failed to enable constraints. One or more rows contain values violating non-null, un [Archive] - PCMech Forums

PDA

View Full Version : "Failed to enable constraints. One or more rows contain values violating non-null, un


gicio
03-03-2003, 03:00 PM
"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:

<error: an exception of type: {System.Data.StrongTypingException} occurred>

(Tables have a relationship to eachother)




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

Paul Victorey
03-03-2003, 11:26 PM
This is Java?

Can you provide the information about OleDbDataAdapter.Fill()?

doctorgonzo
03-04-2003, 09:16 AM
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.

gicio
03-04-2003, 09:26 AM
it's C#



gicio

aym
03-06-2003, 04:29 AM
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.