01.
Private Sub InitAdapter()
02.
Me._adapter = New Global.System.Data.OleDb.OleDbDataAdapter()
03.
Dim tableMapping As Global.System.Data.Common.DataTableMapping = New Global.System.Data.Common.DataTableMapping()
04.
tableMapping.SourceTable =
"Table"
05.
tableMapping.DataSetTable =
"Table1"
06.
tableMapping.ColumnMappings.Add(
"ID"
,
"ID"
)
07.
tableMapping.ColumnMappings.Add(
"type"
,
"type"
)
08.
tableMapping.ColumnMappings.Add(
"count"
,
"count"
)
09.
Me._adapter.TableMappings.Add(tableMapping)
10.
Me._adapter.DeleteCommand = New Global.System.Data.OleDb.OleDbCommand()
11.
Me._adapter.DeleteCommand.Connection = Me.Connection
12.
Me._adapter.DeleteCommand.CommandText =
"DELETE FROM `Table1` WHERE ((`ID` = ?) AND ((? = 1 AND `type` IS NULL) OR (`type`"
& _
13.
" = ?)) AND ((? = 1 AND `count` IS NULL) OR (`count` = ?)))"
14.
Me._adapter.DeleteCommand.CommandType = Global.System.Data.CommandType.Text
15.
Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"Original_ID"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"ID"
, Global.System.Data.DataRowVersion.Original, False, Nothing))
16.
Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"IsNull_type"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"type"
, Global.System.Data.DataRowVersion.Original, True, Nothing))
17.
Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"Original_type"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"type"
, Global.System.Data.DataRowVersion.Original, False, Nothing))
18.
Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"IsNull_count"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"count"
, Global.System.Data.DataRowVersion.Original, True, Nothing))
19.
Me._adapter.DeleteCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"Original_count"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"count"
, Global.System.Data.DataRowVersion.Original, False, Nothing))
20.
Me._adapter.InsertCommand = New Global.System.Data.OleDb.OleDbCommand()
21.
Me._adapter.InsertCommand.Connection = Me.Connection
22.
Me._adapter.InsertCommand.CommandText =
"INSERT INTO `Table1` (`type`, `count`) VALUES (?, ?)"
23.
Me._adapter.InsertCommand.CommandType = Global.System.Data.CommandType.Text
24.
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"type"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"type"
, Global.System.Data.DataRowVersion.Current, False, Nothing))
25.
Me._adapter.InsertCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"count"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"count"
, Global.System.Data.DataRowVersion.Current, False, Nothing))
26.
Me._adapter.UpdateCommand = New Global.System.Data.OleDb.OleDbCommand()
27.
Me._adapter.UpdateCommand.Connection = Me.Connection
28.
Me._adapter.UpdateCommand.CommandText =
"UPDATE `Table1` SET `type` = ?, `count` = ? WHERE ((`ID` = ?) AND ((? = 1 AND `ty"
& _
29.
"pe` IS NULL) OR (`type` = ?)) AND ((? = 1 AND `count` IS NULL) OR (`count` = ?))"
& _
30.
")"
31.
Me._adapter.UpdateCommand.CommandType = Global.System.Data.CommandType.Text
32.
Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"type"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"type"
, Global.System.Data.DataRowVersion.Current, False, Nothing))
33.
Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"count"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"count"
, Global.System.Data.DataRowVersion.Current, False, Nothing))
34.
Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"Original_ID"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"ID"
, Global.System.Data.DataRowVersion.Original, False, Nothing))
35.
Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"IsNull_type"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"type"
, Global.System.Data.DataRowVersion.Original, True, Nothing))
36.
Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"Original_type"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"type"
, Global.System.Data.DataRowVersion.Original, False, Nothing))
37.
Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"IsNull_count"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"count"
, Global.System.Data.DataRowVersion.Original, True, Nothing))
38.
Me._adapter.UpdateCommand.Parameters.Add(New Global.System.Data.OleDb.OleDbParameter(
"Original_count"
, Global.System.Data.OleDb.OleDbType.[Integer], 0, Global.System.Data.ParameterDirection.Input, CType(0, Byte), CType(0, Byte),
"count"
, Global.System.Data.DataRowVersion.Original, False, Nothing))
39.
End Sub