Exception Upon Submitting New Entry

Exception Upon Submitting New Entry

Postby WarMacre » Thu 06 May 2010 16:44

I'm getting an exception when trying to create a new table entry.
The exception is as follows:

A first chance exception of type 'Devart.Data.Linq.LinqCommandExecutionException' occurred in Devart.Data.Linq.dll

I'm using:
dotConnect v5.70.124.0
Visual Studio 2010 v10.0.30319.1 RTMRel
.NET v4.0.30319 RTMRel


I have tried simplifying my code to the bear minimum in order to debug the issue and am convinced it's an issue with DotConnect, but I hope I'm wrong.

Code: Select all
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport.Click
        Try
            Dim context As DataContext1.DataContext1 = New DataContext1.DataContext1
            Dim mono As Monograph1 = New Monograph1

            With mono
                .MonographNumber = 1
                .Title = "Acacia"
            End With

            context.Monograph1s.InsertOnSubmit(mono)
            context.SubmitChanges()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub


The exception occurs upon context.SubmitChanges(), though removing context.Monograph1s.InsertOnSubmit(mono) didn't cause context.SubmitChanges() to throw an exception. But then, that's not hard to see why.

Am I missing something very fundamental?
I'm able to query the DB no problem using the same dataContext, so I know that that is setup correctly.
WarMacre
 
Posts: 6
Joined: Thu 06 May 2010 16:31

Postby WarMacre » Thu 06 May 2010 17:23

OK, instead of using the Devart Linq to SQL Model I have used the Devart Entity Model and used...

Code: Select all
context.AddToMonographs(mono)
context.SaveChanges()


...instead of the InsertOnSubmit and Submit.

Anybody know why the Linq to Sql Model isn't able to submit?
WarMacre
 
Posts: 6
Joined: Thu 06 May 2010 16:31

Postby AndreyR » Fri 07 May 2010 11:24

There are no obvious errors in your code sample.
Could you please send us (support * devart * com, subject "LINQ: SubmitChanges fails") a test project reproducing the problem?
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby WarMacre » Fri 07 May 2010 17:35

Thanks for responding. However, in the process of preparing a file to send to you, I think I may have found the cause of the exception.

I have reduced the columns of the table to only 3 from about 15. Where before I was only inserting data into say 5 of the 15, the test project only entered all 3 of 3 and no exception was thrown, so I believe the error is due to passing null values (nothing in VB) even though the columns have been set as nullable.

Does mySQL not like the nothing value passed by VB when not used? And is it preferable to pass an empty string where applicable?

On another note, the issue I am having now is getting mySQL to accept certain special charcaters like ° and ± where I keep getting 'Incorrect string' exceptions, though if I copy & paste the same characters directly into the tables using a GUI tool it accepts it fine.

Any tips on how to avoid this?
WarMacre
 
Posts: 6
Joined: Thu 06 May 2010 16:31

Postby AndreyR » Tue 11 May 2010 10:12

The test project illustrating the first problem will be great anyway.
As for the second problem, try to set Unicode to true in the connection string.
Please let me know if the second problem persisits.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to dotConnect for MySQL