Skip to content

Commit 6d6fa1b

Browse files
committed
changed error message after dbmapper updating to datagrid showing all errors together with the data leading to the error.
1 parent 95c5f9b commit 6d6fa1b

10 files changed

+3072
-12
lines changed

Distribution/DBaddin32.xll

512 Bytes
Binary file not shown.

Distribution/DBaddin64.xll

512 Bytes
Binary file not shown.

source/DBDocumentation.Designer.vb

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/DBDocumentation.resx

+1,425
Large diffs are not rendered by default.

source/DBMapperErrors.Designer.vb

+60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/DBMapperErrors.resx

+1,545
Large diffs are not rendered by default.

source/DBMapperErrors.vb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Public Class DBMapperErrors
2+
3+
End Class

source/DBModif.vb

+26-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Imports System.Data.OleDb
1111
Imports System.Data.SqlClient
1212
Imports System.Linq
1313
Imports System.Text
14+
Imports System.Windows.Forms
1415

1516

1617
#Region "DBModifs"
@@ -1243,19 +1244,34 @@ nextRow:
12431244
' in this way the actual rows where the database error occured can be retrieved/presented to the user
12441245
da.Update(ds.Tables(0))
12451246
If ds.Tables(0).HasErrors Then
1246-
Dim errMessage As String = ""
1247+
' in case of errors fill a special datagrid with all error messages and the corresponding data that lead to the error
1248+
Dim DBMapperErrorDialog = New DBMapperErrors
1249+
DBMapperErrorDialog.ErrorDataGrid.AutoGenerateColumns = False
1250+
DBMapperErrorDialog.ErrorDataGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllHeaders
1251+
DBMapperErrorDialog.ErrorDataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader
1252+
DBMapperErrorDialog.ErrorDataGrid.RowHeadersWidth = 450
1253+
For i As Integer = 0 To ds.Tables(0).Columns.Count - 1
1254+
Dim colname As String = ds.Tables(0).Columns(i).ToString()
1255+
Dim colDesc As New DataGridViewTextBoxColumn With {
1256+
.Name = colname,
1257+
.HeaderText = colname
1258+
}
1259+
DBMapperErrorDialog.ErrorDataGrid.Columns.Add(colDesc)
1260+
Next
12471261
Try
12481262
For Each row As DataRow In ds.Tables(0).GetErrors()
1249-
errMessage += row.RowError + vbCrLf + vbCrLf
1250-
Dim infoStr As String = ""
1251-
For i As Integer = 0 To row.ItemArray.Count - 1
1252-
infoStr += ds.Tables(0).Columns(i).ToString + ": " + row.ItemArray(i).ToString + vbCrLf
1253-
Next
1254-
errMessage += infoStr + vbCrLf
1263+
Dim newRow = DBMapperErrorDialog.ErrorDataGrid.Rows.Add()
1264+
With DBMapperErrorDialog.ErrorDataGrid
1265+
.Rows(newRow).HeaderCell.Value = row.RowError.Replace(vbLf, "").Replace(vbCr, "")
1266+
For i As Integer = 0 To row.ItemArray.Count - 1
1267+
.Rows(newRow).Cells(i).Value = row.ItemArray(i).ToString()
1268+
Next
1269+
End With
12551270
Next
1256-
Catch ex As Exception : errMessage += ", " + ex.Message : End Try
1257-
' hadError = True ... don't need to set as it is set by notifyUserOfDataError
1258-
If Not notifyUserOfDataError("Update Error in sheet " + TargetRange.Parent.Name + ": " + vbCrLf + errMessage) Then GoTo cleanup
1271+
Catch ex As Exception : End Try
1272+
DBMapperErrorDialog.ShowDialog()
1273+
hadError = True
1274+
GoTo cleanup
12591275
Else
12601276
changesDone = True
12611277
End If

source/DBaddin.vbproj

+9
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
<Compile Include="DBDocumentation.vb">
125125
<SubType>Form</SubType>
126126
</Compile>
127+
<Compile Include="DBMapperErrors.Designer.vb">
128+
<DependentUpon>DBMapperErrors.vb</DependentUpon>
129+
</Compile>
130+
<Compile Include="DBMapperErrors.vb">
131+
<SubType>Form</SubType>
132+
</Compile>
127133
<Compile Include="DBModifHelper.vb" />
128134
<Compile Include="DBSheetConfig.vb" />
129135
<Compile Include="DBSheetCreateForm.designer.vb">
@@ -211,6 +217,9 @@
211217
<EmbeddedResource Include="DBDocumentation.resx">
212218
<DependentUpon>DBDocumentation.vb</DependentUpon>
213219
</EmbeddedResource>
220+
<EmbeddedResource Include="DBMapperErrors.resx">
221+
<DependentUpon>DBMapperErrors.vb</DependentUpon>
222+
</EmbeddedResource>
214223
<EmbeddedResource Include="DBModifCreate.resx">
215224
<DependentUpon>DBModifCreate.vb</DependentUpon>
216225
<SubType>Designer</SubType>

source/My Project/AssemblyInfo.vb

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ Imports System.Runtime.InteropServices
3131
' You can specify all the values or you can default the Build and Revision Numbers
3232
' by using the '*' as shown below:
3333

34-
<Assembly: AssemblyVersion("1.0.0.84")>
35-
<Assembly: AssemblyFileVersion("1.0.0.84")>
34+
<Assembly: AssemblyVersion("1.0.0.85")>
35+
<Assembly: AssemblyFileVersion("1.0.0.85")>
3636
<Assembly: NeutralResourcesLanguage("de-DE")>

0 commit comments

Comments
 (0)