"Failed to enable constraints. One or more rows co

csharp United States
  • 18 years ago



    "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: mdataAdapter.Fill(mdsCarTrade,"CustomerAddress")



    also I get one error in one Row:


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


    (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
               maccessConnection = new OleDbConnection(mconStrAccessConnection);
               maccessCommand = new OleDbCommand(mconStrSelectCommandCustomer, maccessConnection);
               m
    dataAdapter = new OleDbDataAdapter(m_accessCommand);


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


               try
               {
                   mdataAdapter.Fill(mdsCarTrade,"CustomerAddress");


                   mdataAdapter.Fill(mdsCarTrade,"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();
               }


               mdtCustomers = mdsCarTrade.Tables["Customer"];
           }



    [/CODE]


    Know someone why this error caused?






Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“I invented the term Object-Oriented, and I can tell you I did not have C++ in mind.” - Alan Kay