[Mono-bugs] [Bug 553307] New: Datasets and Dataadapters are absolutely not behaving like in Microsoft.Net!
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Nov 6 10:35:02 EST 2009
http://bugzilla.novell.com/show_bug.cgi?id=553307
Summary: Datasets and Dataadapters are absolutely not behaving
like in Microsoft.Net!
Classification: Mono
Product: Mono: Class Libraries
Version: 2.4.x
Platform: i686
OS/Version: openSUSE 11.2
Status: NEW
Severity: Major
Priority: P5 - None
Component: Sys.Data
AssignedTo: bnc-blr-team-mono at forge.provo.novell.com
ReportedBy: jhmgbl2 at t-online.de
QAContact: mono-bugs at lists.ximian.com
Found By: ---
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.11)
Gecko/2009060215 Firefox/3.0.11 (.NET CLR 3.5.30729)
I've tried for days getting a database application to work under Mono, but
everytime I make a workaround, a new error is occurring, which does not exist
under .Net!
Here is my Main piece of Code where most Errors occur:
Public Sub FilldsPPT(ByVal ParentCategoryID As Long, ByVal ParentCategoryRow As
dsPP.ParentCategoriesRow, Optional ByRef DTrans As Sqlite.SqliteTransaction =
Nothing, Optional ByVal Recurse As Boolean = False, Optional ByRef
InternalRecurse As Boolean = False)
Const CodeLoc As String = "clsDBPP.FilldsPPT"
gStatus = CodeLoc & " Start PCat: " & ParentCategoryID
Dim qry As String
Dim Param As SqliteParameter
Dim blnCloseConnection As Boolean
_Initializing = True
Try
retry:
Me.DataSetName = "dsPP"
If (ConPP.State) = ConnectionState.Closed Then
ConPP.Open()
blnCloseConnection = True
End If
' *************** Pictures ***************
gStatus = CodeLoc & " Fill Pictures"
qry = "Select * FROM Pictures WHERE ID IN " & _
"(Select PictureID FROM CategoriesOfPictures WHERE
CategoryID IN " & _
"(Select CategoryID FROM ParentCategories WHERE
ParentCategoryID = ?))"
gStatus = CodeLoc & " Fill Pictures Create Command"
Using cmd As New SqliteCommand(qry, ConPP)
cmd.Transaction = DTrans
gStatus = CodeLoc & " Fill Pictures Add Parameter"
Param = cmd.Parameters.Add("@CategoryID", DbType.Int32, 4)
Param.Direction = ParameterDirection.Input
Param.Value = ParentCategoryID
gStatus = CodeLoc & " Fill Pictures Create Adapter"
Using da As New SqliteDataAdapter(cmd)
#If Not Linux Then
da.Fill(Me, "Pictures")
#Else
gStatus = CodeLoc & " Fill Pictures Getting Rowcount"
If Me.Pictures.Rows.Count > 0 Then
gStatus = CodeLoc & " Fill tmpPictures"
Me.EnforceConstraints = False
da.Fill(_dsTMP, "tmpPictures")
Dim RowCount As Integer = _dsTMP.Tables("tmpPictures").Rows.Count
gStatus = CodeLoc & " Filled tmpPictures count: " & RowCount
If RowCount > 0 Then
gStatus = CodeLoc & " Fill Pictures Set Constraints and Delete
Rules"
Me.EnforceConstraints = False
If Me.relationCat_CatOPics IsNot Nothing AndAlso
Me.relationCat_CatOPics.ChildKeyConstraint IsNot Nothing Then
Me.relationPics_CatOPics.ChildKeyConstraint.DeleteRule =
Rule.None
Me.relationThumbs_Pictures.ChildKeyConstraint.DeleteRule =
Rule.None
End If
gStatus = CodeLoc & " Browse Rows RowCount: " & RowCount
Dim first As Boolean = True
For Each r As DataRow In _dsTMP.Tables("tmpPictures").Rows
If first Then
gStatus = CodeLoc & " Browse Rows Start"
first = False
End If
Dim drPics As dsPP.PicturesRow =
Me.Pictures.FindByID(CLng(r!ID))
If drPics IsNot Nothing Then
gStatus = CodeLoc & " Not Importing PicRow " & drPics.Name
Else
gStatus = CodeLoc & " Importing PicRow " & CStr(r!Name)
Me.Pictures.ImportRow(r)
End If
Next
If Me.relationCat_CatOPics IsNot Nothing AndAlso
Me.relationCat_CatOPics.ChildKeyConstraint IsNot Nothing Then
Me.relationPics_CatOPics.ChildKeyConstraint.DeleteRule =
Rule.Cascade
Me.relationThumbs_Pictures.ChildKeyConstraint.DeleteRule =
Rule.Cascade
End If
gStatus = CodeLoc & " EnforceConstraints"
End If
gStatus = CodeLoc & "Clear tmpPictures"
_dsTMP.Tables.Remove("tmpPictures")
Me.EnforceConstraints = True
Else
da.Fill(Me, "Pictures")
End If
#End If
End Using
End Using
'********************* Categories *************************
gStatus = CodeLoc & " Fill Categories"
qry = "Select * FROM Categories WHERE ID IN (Select CategoryID FROM
ParentCategories WHERE ParentCategoryID = ?)"
Using cmd As New SqliteCommand(qry, ConPP)
cmd.Transaction = DTrans
Param = cmd.Parameters.Add("@CategoryID", DbType.Int32, 4)
Param.Direction = ParameterDirection.Input
Param.Value = ParentCategoryID
Using da As New SqliteDataAdapter(cmd)
#If Not Linux Then
da.Fill(Me, "Categories")
#Else
If Me.Categories.Rows.Count > 0 Then
Me.EnforceConstraints = False
da.Fill(_dsTMP, "tmpCategories")
Dim RowCount As Integer = _dsTMP.Tables("tmpCategories").RowsCount
If RowCount > 0 Then
If Me.relationParentCatCat_Cat IsNot Nothing AndAlso
Me.relationParentCatCat_Cat.ChildKeyConstraint IsNot Nothing Then
Me.relationParentCatCat_Cat.ChildKeyConstraint.DeleteRule =
Rule.None
Me.relationParentCatParentCat_Cat.ChildKeyConstraint.DeleteRule
= Rule.None
Me.relationCat_CatOPics.ChildKeyConstraint.DeleteRule =
Rule.None
End If
Me.EnforceConstraints = False
For Each r As DataRow In _dsTMP.Tables("tmpCategories").Rows
Dim drCategories As dsPP.CategoriesRow =
Me.Categories.FindByID(CLng(r!ID))
If drCategories IsNot Nothing Then
Else
Me.Categories.ImportRow(r)
End If
Next
If Me.relationParentCatCat_Cat IsNot Nothing AndAlso
Me.relationParentCatCat_Cat.ChildKeyConstraint IsNot Nothing Then
Me.relationParentCatCat_Cat.ChildKeyConstraint.DeleteRule =
Rule.Cascade
Me.relationParentCatParentCat_Cat.ChildKeyConstraint.DeleteRule
= Rule.Cascade
Me.relationCat_CatOPics.ChildKeyConstraint.DeleteRule =
Rule.Cascade
End If
End If
_dsTMP.Tables.Remove("tmpCategories")
Me.EnforceConstraints = True
Else
da.Fill(Me, "Categories")
End If
#End If
End Using
End Using
'*****************CatOPics************************
gStatus = CodeLoc & " Fill CatOPics"
qry = "Select * FROM CategoriesOfPictures WHERE CategoryID IN " & _
"(Select CategoryID FROM ParentCategories WHERE
ParentCategoryID = ?)"
Using cmd As New SqliteCommand(qry, ConPP)
cmd.Transaction = DTrans
Param = cmd.Parameters.Add("@CategoryID", DbType.Int32, 4)
Param.Direction = ParameterDirection.Input
Param.Value = ParentCategoryID
Using da As New SqliteDataAdapter(cmd)
#If Not Linux Then
da.Fill(Me, "CategoriesOfPictures")
#Else
If Me.CategoriesOfPictures.Rows.Count > 0 Then
Me.EnforceConstraints = False
da.Fill(_dsTMP, "tmpCategoriesOfPictures")
For Each r As DataRow In
_dsTMP.Tables("tmpCategoriesOfPictures").Rows
Dim drCategoriesOfPictures As dsPP.CategoriesOfPicturesRow =
Me.CategoriesOfPictures.FindByID(CLng(r!ID))
If drCategoriesOfPictures IsNot Nothing Then
'Me.CategoriesOfPictures.RemoveCategoriesOfPicturesRow(drCategoriesOfPictures)
Else
Me.CategoriesOfPictures.ImportRow(r)
End If
Next
_dsTMP.Tables.Remove("tmpCategoriesOfPictures")
Me.EnforceConstraints = True
Else
da.Fill(Me, "CategoriesOfPictures")
End If
#End If
End Using
End Using
' *********************ParentCategories*********************
gStatus = CodeLoc & " Fill ParentCategories"
qry = "Select * FROM ParentCategories WHERE ParentCategoryID = ?"
Using cmd As New SqliteCommand(qry, ConPP)
cmd.Transaction = DTrans
Param = cmd.Parameters.Add("@CategoryID", DbType.Int32, 4)
Param.Direction = ParameterDirection.Input
Param.Value = ParentCategoryID
Using da As New SqliteDataAdapter(cmd)
Dim Retrys As Integer
Try
RetryFillPCat:
#If Not Linux Then
da.Fill(Me, "ParentCategories")
#Else
If Me.ParentCategories.Rows.Count > 0 Then
Me.EnforceConstraints = False
da.Fill(_dsTMP, "tmpParentCategories")
For Each r As DataRow In
_dsTMP.Tables("tmpParentCategories").Rows
Dim drParentCategories As dsPP.ParentCategoriesRow =
Me.ParentCategories.FindByID(CLng(r!ID))
If drParentCategories IsNot Nothing Then
'Me.ParentCategories.RemoveParentCategoriesRow(drParentCategories)
Else
Me.ParentCategories.ImportRow(r)
End If
Next
_dsTMP.Tables.Remove("tmpParentCategories")
Me.EnforceConstraints = True
Else
da.Fill(Me, "ParentCategories")
End If
#End If
Catch ex As ConstraintException
gStatus = CodeLoc & " Fill ParentCategories Constraintexception"
RemoveNonExistentEntrysFROMParentCategories()
Retrys += 1
' Da die Einträge trotz Fehlers geladen werden müssen sie vor einem
erneuten Versuch erst gelöscht werden.
For Each r As DataRow In
Me.ParentCategories.Select("ParentCategoryID = " & ParentCategoryID)
Me.ParentCategories.Rows.Remove(r)
Next
#If Linux Then
If _dsTMP.Tables("tmpParentCategories") IsNot Nothing Then
_dsTMP.Tables.Remove("tmpParentCategories")
End If
#End If
Me.EnforceConstraints = True
If Retrys < 2 Then GoTo RetryFillPCat
RemoveDoubleEntriesFromParentCategories()
If Retrys < 3 Then GoTo RetryfillpCat
End Try
End Using
End Using
''***********************Thumbs*************************
'qry = "Select * FROM Thumbs where PictureID IN " & _
' "(Select ID FROM Pictures WHERE ID IN " & _
' "(Select PictureID FROM CategoriesOfPictures WHERE
CategoryID IN " & _
' "(Select CategoryID FROM ParentCategories WHERE
ParentCategoryID = ?)))"
'Using cmd As New SQLiteCommand(qry, ConPP)
' Param = cmd.Parameters.Add("@CategoryID", DbType.Int32, 4)
' Param.Direction = ParameterDirection.Input
' Param.Value = ParentCategoryID
' Using da As New SQLiteDataAdapter(cmd)
' da.Fill(Me, "Thumbs")
' End Using
'End Using
'***********************FavFolder*************************
gStatus = CodeLoc & " Fill FavFolder"
If Me.FavFolder.Count = 0 Then
Using da As New SqliteDataAdapter("Select * FROM FavFolder", ConPP)
da.SelectCommand.Transaction = DTrans
da.Fill(Me, "FavFolder")
End Using
End If
'***********************Favorites*************************
gStatus = CodeLoc & " Fill Favorites"
If Me.Favorites.Count = 0 Then
Using da As New SqliteDataAdapter("Select * FROM Favorites", ConPP)
da.SelectCommand.Transaction = DTrans
da.Fill(Me, "Favorites")
End Using
End If
If Recurse Then
Static LastPCats As System.Collections.ObjectModel.Collection(Of Long)
If InternalRecurse = False Then
LastPCats = New System.Collections.ObjectModel.Collection(Of Long)
End If
LastPCats.Add(ParentCategoryID)
If ParentCategoryRow Is Nothing Then
Throw New ApplicationException("ParentCat is nothing on recurse!")
End If
For Each PCat As dsPP.ParentCategoriesRow In
ParentCategoryRow.CategoriesRowByParentCatCat_Cat.GetParentCategoriesRowsByParentCatParentCat_Cat
If Not LastPCats.Contains(PCat.CategoryID) Then
FilldsPPT(PCat.CategoryID, PCat, DTrans, Recurse, True)
End If
Next
End If
Catch ex As Exception
HandleError(ex, "dsPP.FillDSPPT")
Finally
If blnCloseConnection Then
ConPP.Close()
End If
_Initializing = False
End Try
End Sub
Reproducible: Always
Steps to Reproduce:
1.
2.
3.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list