Problem with BindingSource

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Problem with BindingSource

Post by Zero-G. » Wed 10 Feb 2010 16:00

Hey

Don't know if you got my yesterday mail, but:
When using the following code:

Code: Select all

        If Me.BindingSource2.Current IsNot Nothing Then
            Me.BindingSource2.RemoveAt(0)
        End If
        Dim newInfo As New Voptneucontext.Auftragdetail With {.Artikelbezeichnung = Me.TextBox1.Text}
        Me.BindingSource2.Add(newInfo)
        BindingSource2.EndEdit()
        BindingSource1.EndEdit()
        myDataContext.SubmitChanges()
By calling SubmitChanges, I get the following error:

'By calling the SubmitChanges Statement, I get the following error:
'"Cannot add or update a child row: a foreign key constraint fails (`voptneu`.`auftragdetails`, CONSTRAINT `rel_auftragdetail_auftrag` FOREIGN KEY (`auftragid`) REFERENCES `auftrag` (`id`) ON DELETE CASCADE)"}

But only, when I remove an item.

Any ideas?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 11 Feb 2010 13:10

I have replied to you by e-mail.

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Tue 16 Feb 2010 11:56

Hey
It doesn't work in my running project.
I did the code like you provided.
First adding the new entrie and then delete (with RemoveAt)
The same error occured, like I wrote in the first post.
Now, I found out, that the following command is created:

Code: Select all

UPDATE auftragdetails SET auftragid = :p1 WHERE id = :key1 AND auftragid = :key2 AND ((:nullkey3 = 1 AND artikelid IS NULL) OR (artikelid = :key3)) AND ((:nullkey4 = 1 AND invnr IS NULL) OR (invnr = :key4)) AND lieferant = :key5 AND ((:nullkey6 = 1 AND artikelnr IS NULL) OR (artikelnr = :key6)) AND ((:nullkey7 = 1 AND groesse IS NULL) OR (groesse = :key7)) AND ((:nullkey8 = 1 AND farbe IS NULL) OR (farbe = :key8)) AND ((:nullkey9 = 1 AND glasfarbe IS NULL) OR (glasfarbe = :key9)) AND ((:nullkey10 = 1 AND glasentspiegelung IS NULL) OR (glasentspiegelung = :key10)) AND ((:nullkey11 = 1 AND glasgroesse IS NULL) OR (glasgroesse = :key11)) AND ((:nullkey12 = 1 AND ArtikelBezeichnung IS NULL) OR (ArtikelBezeichnung = :key12)) AND ((:nullkey13 = 1 AND icode IS NULL) OR (icode = :key13)) AND ((:nullkey14 = 1 AND menge IS NULL) OR (menge = :key14)) AND ((:nullkey15 = 1 AND Preis IS NULL) OR (Preis = :key15)) AND ((:nullkey16 = 1 AND Gesamtpreis IS NULL) OR (Gesamtpreis = :key16)) AND zuordnung = :key17 AND Zeitstempel = :key18
ParameterName = p1
DbType = Int64
Value = 0
ParameterName = key1
DbType = Int64
Value = 98089
ParameterName = key2
DbType = Int64
Value = 53434
ParameterName = nullkey3
DbType = Int32
Value = 0
ParameterName = key3
DbType = Int64
Value = 11807
ParameterName = nullkey4
DbType = Int32
Value = 0
ParameterName = key4
DbType = AnsiStringFixedLength
Value = X
ParameterName = key5
DbType = Int64
Value = 99
ParameterName = nullkey6
DbType = Int32
Value = 0
ParameterName = key6
DbType = AnsiStringFixedLength
Value = DIV
ParameterName = nullkey7
DbType = Int32
Value = 0
ParameterName = key7
DbType = AnsiStringFixedLength
Value = 
ParameterName = nullkey8
DbType = Int32
Value = 0
ParameterName = key8
DbType = AnsiStringFixedLength
Value = 
ParameterName = nullkey9
DbType = Int32
Value = 1
ParameterName = key9
DbType = AnsiStringFixedLength
Value = 
ParameterName = nullkey10
DbType = Int32
Value = 1
ParameterName = key10
DbType = AnsiStringFixedLength
Value = 
ParameterName = nullkey11
DbType = Int32
Value = 1
ParameterName = key11
DbType = Int32
Value = 
ParameterName = nullkey12
DbType = Int32
Value = 0
ParameterName = key12
DbType = AnsiStringFixedLength
Value = Diverser Artikel
ParameterName = nullkey13
DbType = Int32
Value = 0
ParameterName = key13
DbType = Int64
Value = 12371
ParameterName = nullkey14
DbType = Int32
Value = 0
ParameterName = key14
DbType = Int32
Value = 1
ParameterName = nullkey15
DbType = Int32
Value = 0
ParameterName = key15
DbType = Double
Value = 2,16
ParameterName = nullkey16
DbType = Int32
Value = 1
ParameterName = key16
DbType = Double
Value = 
ParameterName = key17
DbType = Int16
Value = 1
ParameterName = key18
DbType = DateTime
Value = 16.02.2010 09:42:45
The update command would like to update only the row, which should be deleted. As you can see, the code tries to update the row and set the auftragid to 0 - but this is not compatible with my foreign key settings. - Please take a new look to this problem
The entrie should be deleted and added new. - Or the update command should set the new values to the row.

THX

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 17 Feb 2010 10:07

I failed to reproduce the problem.
Value for the auftragid parameter is correct (1, not 0) in my case.
Please resend me the project you encounter the problem in.

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Wed 17 Feb 2010 12:32

Hey

I use version 5.50.57
Could that be the problem? - I have sended you the testproject.
Which version can I use in a productiv environment, where this error should not occur?

THX

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 17 Feb 2010 15:17

Yes, it is likely to be the reason. I have replied to your Beta/Productive question in this post:
http://www.devart.com/forums/viewtopic.php?t=17136

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Wed 17 Feb 2010 15:46

Hey

Updated to the latestet BETA Version.
Still no chance to get it working! - I have mailed you my Database Structure. - Please take a look

THX

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 19 Feb 2010 13:23

I have replied to you by e-mail.

Post Reply