質問編集履歴

2

タグの変更

2019/02/13 02:18

投稿

kirinsan
kirinsan

スコア13

test CHANGED
File without changes
test CHANGED
File without changes

1

ソースの記載

2019/02/13 02:18

投稿

kirinsan
kirinsan

スコア13

test CHANGED
File without changes
test CHANGED
@@ -79,3 +79,359 @@
79
79
 
80
80
 
81
81
  よろしくお願いします。
82
+
83
+
84
+
85
+
86
+
87
+ === 追記 ===
88
+
89
+ ソースは以下のように記述しています。
90
+
91
+
92
+
93
+ ```ASP.net
94
+
95
+ Dim SE As New clsDbAccess
96
+
97
+ Dim MySqlSE As New clsMySqlAccess
98
+
99
+
100
+
101
+ '***** MySql接続設定開始 *****
102
+
103
+ MySqlSE.ConnectionString = "接続文字列"
104
+
105
+ MySqlSE.CommandTimeout = CommandTimeout
106
+
107
+
108
+
109
+ '### トランザクション
110
+
111
+ MySqlSE.BeginTransaction()
112
+
113
+ '***** MySql接続設定終了 *****
114
+
115
+
116
+
117
+ '### 接続コネクション設定(SqlServer)
118
+
119
+ SE.ConnectionString = "接続文字列"
120
+
121
+ SE.CommandTimeout = CommandTimeout
122
+
123
+
124
+
125
+ '### トランザクション
126
+
127
+ SE.BeginTransaction()
128
+
129
+
130
+
131
+ '
132
+
133
+ 'SQLServerに対する更新処理
134
+
135
+ '~~
136
+
137
+ '
138
+
139
+
140
+
141
+ 'SQLServer⇒MySQLへのデータ流し込み
142
+
143
+
144
+
145
+ ''deleteその1
146
+
147
+ strSQL = "DELETE FROM tableA_MySQL WHERE ~"
148
+
149
+
150
+
151
+ MySqlSE.CommandString = strSQL
152
+
153
+ MySqlSE.ExecuteTSQL()
154
+
155
+
156
+
157
+ ''selectその1
158
+
159
+ strSQL = "SELECT * FROM tableB_SQLServer WHERE ~"
160
+
161
+
162
+
163
+ SE.TableName = "RESULT"
164
+
165
+ SE.CommandString = strSQL
166
+
167
+ SE.ExecuteSQL()
168
+
169
+
170
+
171
+ Dim DT_TMP As DataTable = Nothing
172
+
173
+ DT_TMP = SE.TableData.Tables(SE.TableName)
174
+
175
+
176
+
177
+ For i = 0 To DT_TMP.Rows.Count - 1
178
+
179
+ ''insertその1
180
+
181
+ strSQL = " INSERT INTO tableC_MySQL (~) VALUES (~) "
182
+
183
+
184
+
185
+ MySqlSE.CommandString = strSQL
186
+
187
+ MySqlSE.ExecuteTSQL()
188
+
189
+ Next
190
+
191
+
192
+
193
+ ''deleteその2
194
+
195
+ strSQL = "DELETE FROM tableD_MySQL WHERE ~"
196
+
197
+
198
+
199
+ MySqlSE.CommandString = strSQL
200
+
201
+ MySqlSE.ExecuteTSQL()
202
+
203
+
204
+
205
+ ''selectその2
206
+
207
+ strSQL = "SELECT * FROM tableE_SQLServer WHERE ~"
208
+
209
+
210
+
211
+ SE.TableName = "RESULT"
212
+
213
+ SE.CommandString = strSQL
214
+
215
+ SE.ExecuteSQL()
216
+
217
+
218
+
219
+ Dim DT_TMP As DataTable = Nothing
220
+
221
+ DT_TMP = SE.TableData.Tables(SE.TableName)
222
+
223
+
224
+
225
+ For i = 0 To DT_TMP.Rows.Count - 1
226
+
227
+ ''insertその2
228
+
229
+ strSQL = " INSERT INTO tableF_MySQL (~) VALUES (~) "
230
+
231
+
232
+
233
+ MySqlSE.CommandString = strSQL
234
+
235
+ MySqlSE.ExecuteTSQL()
236
+
237
+ Next
238
+
239
+
240
+
241
+ ''deleteその3
242
+
243
+ strSQL = "DELETE FROM tableG_MySQL WHERE ~"
244
+
245
+
246
+
247
+ MySqlSE.CommandString = strSQL
248
+
249
+ MySqlSE.ExecuteTSQL()
250
+
251
+
252
+
253
+ ''selectその3
254
+
255
+ strSQL = "SELECT * FROM tableH_SQLServer WHERE ~"
256
+
257
+
258
+
259
+ SE.TableName = "RESULT"
260
+
261
+ SE.CommandString = strSQL
262
+
263
+ SE.ExecuteSQL()
264
+
265
+
266
+
267
+ Dim DT_TMP As DataTable = Nothing
268
+
269
+ DT_TMP = SE.TableData.Tables(SE.TableName)
270
+
271
+
272
+
273
+ For i = 0 To DT_TMP.Rows.Count - 1
274
+
275
+ ''insertその3
276
+
277
+ strSQL = " INSERT INTO tableI_MySQL (~) VALUES (~) "
278
+
279
+
280
+
281
+ MySqlSE.CommandString = strSQL
282
+
283
+ MySqlSE.ExecuteTSQL()
284
+
285
+ Next
286
+
287
+
288
+
289
+ '### コミット(SqlServer)
290
+
291
+ SE.Commit()
292
+
293
+
294
+
295
+ '### コミット(MySql)
296
+
297
+ MySqlSE.Commit()
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+ '' クラス定義
308
+
309
+ Public Class clsMySqlAccess
310
+
311
+ Public Function ExecuteTSQL() As Boolean
312
+
313
+
314
+
315
+ 'トランザクションが開始されているかどうか
316
+
317
+ If _sqlTransaction Is Nothing Then
318
+
319
+ OpenConnection()
320
+
321
+ _sqlCommand = New MySqlCommand(_commandString, _sqlConnection)
322
+
323
+ _sqlCommand = _sqlConnection.CreateCommand
324
+
325
+
326
+
327
+ _sqlCommand.CommandTimeout = _commandTimeout
328
+
329
+ Else
330
+
331
+ _sqlCommand = New MySqlCommand(_commandString, _sqlConnection)
332
+
333
+ _sqlCommand.Transaction = _sqlTransaction
334
+
335
+ _sqlCommand.CommandTimeout = _commandTimeout
336
+
337
+ End If
338
+
339
+
340
+
341
+ _executeCount = _sqlCommand.ExecuteNonQuery()
342
+
343
+
344
+
345
+ If _sqlTransaction Is Nothing Then
346
+
347
+ CloseConnection()
348
+
349
+ End If
350
+
351
+
352
+
353
+ Return True
354
+
355
+
356
+
357
+ End Function
358
+
359
+ End Class
360
+
361
+
362
+
363
+ Public Class clsDbAccess
364
+
365
+ Public Function ExecuteSQL() As Boolean
366
+
367
+
368
+
369
+ Dim DS As New DataSet()
370
+
371
+
372
+
373
+ 'トランザクションが開始されているかどうか
374
+
375
+ If _sqlTransaction Is Nothing Then
376
+
377
+ OpenConnection()
378
+
379
+ _sqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter()
380
+
381
+ _sqlDataAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(_commandString, _sqlConnection)
382
+
383
+ _sqlDataAdapter.SelectCommand.CommandTimeout = _commandTimeout
384
+
385
+ Else
386
+
387
+ _sqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter()
388
+
389
+ _sqlDataAdapter.SelectCommand = New System.Data.SqlClient.SqlCommand(_commandString, _sqlConnection)
390
+
391
+ _sqlDataAdapter.SelectCommand.Transaction = _sqlTransaction
392
+
393
+ _sqlDataAdapter.SelectCommand.CommandTimeout = _commandTimeout
394
+
395
+ End If
396
+
397
+
398
+
399
+ 'DataSetにSelect結果を格納
400
+
401
+ _sqlDataAdapter.Fill(DS, _tableName)
402
+
403
+ _executeCount = DS.Tables(0).Rows.Count
404
+
405
+
406
+
407
+ _tableData = DS
408
+
409
+
410
+
411
+ If _sqlTransaction Is Nothing Then
412
+
413
+ CloseConnection()
414
+
415
+ End If
416
+
417
+
418
+
419
+ Return True
420
+
421
+
422
+
423
+ End Function
424
+
425
+ End Class
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+ ```