質問編集履歴
9
使っているツールのバージョンなど補足情報を追加いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -130,11 +130,13 @@
|
|
130
130
|
|
131
131
|
ACCESSのバージョン2103
|
132
132
|
|
133
|
-
|
133
|
+
Windows10の64ビット
|
134
134
|
|
135
|
-
|
135
|
+
WindowsFormsを作成
|
136
136
|
|
137
|
+
Visual Studio2019
|
137
138
|
|
139
|
+
NET Framework 4.8を使用してます。
|
138
140
|
|
139
141
|
|
140
142
|
|
8
ダブルクォートを追加いたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
前提・実現したいこと
|
2
2
|
|
3
|
-
VB.NET
|
3
|
+
VB.NETにAccessのデータを取得したいです。
|
4
4
|
|
5
5
|
|
6
6
|
|
7
ダブルクォートを追加いたします。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VB.NET
|
1
|
+
VB.NETにAccessのデータを取得したいです。
|
test
CHANGED
File without changes
|
6
ダブルクォートを追加いたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
発生している問題・エラーメッセージ
|
8
8
|
|
9
9
|
BC30590 イベントLoadが見つかりません。とエラーが表示されます。
|
10
|
+
|
11
|
+
エラーは二行目「 Private Sub frmConnectAccessDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load」の最後のLoadで発生してます。
|
10
12
|
|
11
13
|
|
12
14
|
|
@@ -126,9 +128,13 @@
|
|
126
128
|
|
127
129
|
使っているツールのバージョンなど補足情報
|
128
130
|
|
129
|
-
|
131
|
+
ACCESSのバージョン2103
|
130
132
|
|
131
|
-
|
133
|
+
VB.netでWindows10の64ビット
|
134
|
+
|
135
|
+
Visual Studioを使用してます。
|
136
|
+
|
137
|
+
|
132
138
|
|
133
139
|
|
134
140
|
|
5
ダブルクォートを追加いたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,211 +18,101 @@
|
|
18
18
|
|
19
19
|
Public Class frmConnectAccessDB
|
20
20
|
|
21
|
-
```
|
22
|
-
|
23
|
-
```
|
24
|
-
|
25
|
-
Private Sub frmConnectAccessDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
21
|
+
Private Sub frmConnectAccessDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
26
|
-
|
27
|
-
```
|
28
22
|
|
29
23
|
|
30
24
|
|
31
|
-
'SQL作成
|
25
|
+
'SQL作成
|
32
26
|
|
27
|
+
Dim resultDt As New DataTable
|
33
28
|
|
29
|
+
Dim sql = New System.Text.StringBuilder()
|
34
30
|
|
35
|
-
|
31
|
+
sql.AppendLine("SELECT")
|
36
32
|
|
37
|
-
|
33
|
+
sql.AppendLine(" *")
|
38
34
|
|
39
|
-
```
|
40
|
-
|
41
|
-
```
|
42
|
-
|
43
|
-
Dim sql = New System.Text.StringBuilder()
|
44
|
-
|
45
|
-
```
|
46
|
-
|
47
|
-
```
|
48
|
-
|
49
|
-
sql.AppendLine("SELECT")
|
50
|
-
|
51
|
-
```
|
52
|
-
|
53
|
-
```
|
54
|
-
|
55
|
-
sql.AppendLine(" *")
|
56
|
-
|
57
|
-
```
|
58
|
-
|
59
|
-
```
|
60
|
-
|
61
|
-
sql.AppendLine("FROM ID給料")
|
35
|
+
sql.AppendLine("FROM ID給料")
|
62
|
-
|
63
|
-
```
|
64
36
|
|
65
37
|
|
66
38
|
|
67
39
|
'Access接続準備
|
68
40
|
|
69
|
-
|
41
|
+
Dim command As New OleDbCommand
|
70
42
|
|
71
|
-
Dim
|
43
|
+
Dim da As New OleDbDataAdapter
|
72
44
|
|
73
|
-
|
45
|
+
Dim cnAccess As OleDbConnection = New OleDbConnection
|
74
46
|
|
75
|
-
```
|
76
|
-
|
77
|
-
Dim da As New OleDbDataAdapter
|
78
|
-
|
79
|
-
```
|
80
|
-
|
81
|
-
```
|
82
|
-
|
83
|
-
Dim cnAccess As OleDbConnection = New OleDbConnection
|
84
|
-
|
85
|
-
cnAccess.ConnectionString = My.Settings.アクセス
|
47
|
+
cnAccess.ConnectionString = My.Settings.アクセス
|
86
|
-
|
87
|
-
```
|
88
48
|
|
89
49
|
|
90
50
|
|
91
51
|
'Access接続開始
|
92
52
|
|
93
|
-
```
|
94
|
-
|
95
|
-
cnAccess.Open()
|
53
|
+
cnAccess.Open()
|
96
|
-
|
97
|
-
```
|
98
|
-
|
99
|
-
```
|
100
|
-
|
101
|
-
Try
|
102
|
-
|
103
|
-
```
|
104
|
-
|
105
|
-
```
|
106
|
-
|
107
|
-
command.Connection = cnAccess
|
108
|
-
|
109
|
-
```
|
110
|
-
|
111
|
-
```
|
112
|
-
|
113
|
-
command.CommandText = sql.ToString
|
114
|
-
|
115
|
-
```
|
116
|
-
|
117
|
-
```
|
118
|
-
|
119
|
-
da.SelectCommand = command
|
120
|
-
|
121
|
-
```
|
122
54
|
|
123
55
|
|
124
56
|
|
125
|
-
'SQL実行 結果をデータテーブルに格納
|
126
|
-
|
127
|
-
```
|
128
|
-
|
129
|
-
da.Fill(resultDt)
|
130
|
-
|
131
|
-
```
|
132
|
-
|
133
|
-
```
|
134
|
-
|
135
|
-
Catch ex As Exception
|
136
|
-
|
137
|
-
```
|
138
|
-
|
139
|
-
```
|
140
|
-
|
141
|
-
T
|
57
|
+
Try
|
142
|
-
|
143
|
-
```
|
144
|
-
|
145
|
-
```
|
146
|
-
|
147
|
-
Finally
|
148
|
-
|
149
|
-
```
|
150
|
-
|
151
|
-
```
|
152
|
-
|
153
|
-
command.Dispose()
|
154
|
-
|
155
|
-
```
|
156
|
-
|
157
|
-
```
|
158
|
-
|
159
|
-
da.Dispose()
|
160
|
-
|
161
|
-
```
|
162
|
-
|
163
|
-
```
|
164
|
-
|
165
|
-
cnAccess.Close()
|
166
|
-
|
167
|
-
```
|
168
|
-
|
169
|
-
```
|
170
|
-
|
171
|
-
End Try
|
172
|
-
|
173
|
-
```
|
174
58
|
|
175
59
|
|
176
60
|
|
61
|
+
command.Connection = cnAccess
|
62
|
+
|
63
|
+
command.CommandText = sql.ToString
|
64
|
+
|
177
|
-
|
65
|
+
da.SelectCommand = command
|
178
66
|
|
179
67
|
|
180
68
|
|
181
|
-
|
69
|
+
'SQL実行 結果をデータテーブルに格納
|
182
70
|
|
183
|
-
|
71
|
+
da.Fill(resultDt)
|
184
72
|
|
185
|
-
```
|
186
73
|
|
187
|
-
```
|
188
74
|
|
189
|
-
For colindex As Integer = 0 To resultDt.Columns.Count - 1
|
190
75
|
|
191
|
-
```
|
192
76
|
|
193
|
-
|
77
|
+
Catch ex As Exception
|
194
78
|
|
195
|
-
|
79
|
+
Throw
|
196
80
|
|
197
|
-
|
81
|
+
Finally
|
198
82
|
|
199
|
-
|
83
|
+
command.Dispose()
|
200
84
|
|
201
|
-
|
85
|
+
da.Dispose()
|
202
86
|
|
203
|
-
|
87
|
+
cnAccess.Close()
|
204
88
|
|
205
|
-
|
89
|
+
End Try
|
206
90
|
|
207
|
-
Console.WriteLine()
|
208
91
|
|
209
|
-
```
|
210
92
|
|
211
|
-
|
93
|
+
'データテーブルの結果を表示
|
212
94
|
|
213
|
-
|
95
|
+
For rowindex As Integer = 0 To resultDt.Rows.Count - 1
|
214
96
|
|
215
|
-
|
97
|
+
For colindex As Integer = 0 To resultDt.Columns.Count - 1
|
216
98
|
|
217
|
-
|
99
|
+
Console.Write(resultDt.Rows(rowindex).Item(colindex).ToString & " ")
|
218
100
|
|
219
|
-
|
101
|
+
Next
|
220
102
|
|
221
|
-
|
103
|
+
Console.WriteLine()
|
222
104
|
|
223
|
-
|
105
|
+
Next
|
224
106
|
|
107
|
+
|
108
|
+
|
109
|
+
End Sub
|
110
|
+
|
225
|
-
End Class
|
111
|
+
End Class
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
226
116
|
|
227
117
|
```
|
228
118
|
|
4
ダブルクォートを追加いたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,99 +14,217 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
+
```
|
18
|
+
|
17
|
-
|
19
|
+
Public Class frmConnectAccessDB
|
20
|
+
|
18
|
-
|
21
|
+
```
|
22
|
+
|
23
|
+
```
|
24
|
+
|
19
|
-
|
25
|
+
Private Sub frmConnectAccessDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
26
|
+
|
20
|
-
|
27
|
+
```
|
21
|
-
|
22
|
-
|
28
|
+
|
29
|
+
|
30
|
+
|
23
|
-
|
31
|
+
'SQL作成
|
32
|
+
|
33
|
+
|
34
|
+
|
24
|
-
|
35
|
+
```
|
36
|
+
|
25
|
-
|
37
|
+
Dim resultDt As New DataTable
|
38
|
+
|
26
|
-
|
39
|
+
```
|
40
|
+
|
41
|
+
```
|
42
|
+
|
27
|
-
|
43
|
+
Dim sql = New System.Text.StringBuilder()
|
44
|
+
|
28
|
-
|
45
|
+
```
|
46
|
+
|
47
|
+
```
|
48
|
+
|
29
|
-
|
49
|
+
sql.AppendLine("SELECT")
|
50
|
+
|
30
|
-
|
51
|
+
```
|
52
|
+
|
53
|
+
```
|
54
|
+
|
31
|
-
|
55
|
+
sql.AppendLine(" *")
|
56
|
+
|
32
|
-
|
57
|
+
```
|
58
|
+
|
59
|
+
```
|
60
|
+
|
33
|
-
|
61
|
+
sql.AppendLine("FROM ID給料")
|
62
|
+
|
63
|
+
```
|
34
64
|
|
35
65
|
|
36
66
|
|
37
67
|
'Access接続準備
|
38
68
|
|
69
|
+
```
|
70
|
+
|
39
|
-
|
71
|
+
Dim command As New OleDbCommand
|
72
|
+
|
40
|
-
|
73
|
+
```
|
74
|
+
|
75
|
+
```
|
76
|
+
|
41
|
-
|
77
|
+
Dim da As New OleDbDataAdapter
|
78
|
+
|
42
|
-
|
79
|
+
```
|
80
|
+
|
81
|
+
```
|
82
|
+
|
43
|
-
|
83
|
+
Dim cnAccess As OleDbConnection = New OleDbConnection
|
44
|
-
|
84
|
+
|
45
|
-
cnAccess.ConnectionString = My.Settings.アクセス
|
85
|
+
cnAccess.ConnectionString = My.Settings.アクセス
|
86
|
+
|
87
|
+
```
|
46
88
|
|
47
89
|
|
48
90
|
|
49
91
|
'Access接続開始
|
50
92
|
|
51
|
-
```
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
```
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
93
|
+
```
|
94
|
+
|
95
|
+
cnAccess.Open()
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
Try
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
```
|
106
|
+
|
107
|
+
command.Connection = cnAccess
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
command.CommandText = sql.ToString
|
114
|
+
|
115
|
+
```
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
da.SelectCommand = command
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
'SQL実行 結果をデータテーブルに格納
|
126
|
+
|
127
|
+
```
|
128
|
+
|
129
|
+
da.Fill(resultDt)
|
130
|
+
|
131
|
+
```
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
Catch ex As Exception
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
```
|
140
|
+
|
141
|
+
Throw
|
142
|
+
|
143
|
+
```
|
144
|
+
|
145
|
+
```
|
146
|
+
|
147
|
+
Finally
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
command.Dispose()
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
da.Dispose()
|
160
|
+
|
161
|
+
```
|
162
|
+
|
163
|
+
```
|
164
|
+
|
165
|
+
cnAccess.Close()
|
166
|
+
|
167
|
+
```
|
168
|
+
|
169
|
+
```
|
170
|
+
|
171
|
+
End Try
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
'データテーブルの結果を表示
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
```
|
182
|
+
|
183
|
+
For rowindex As Integer = 0 To resultDt.Rows.Count - 1
|
184
|
+
|
185
|
+
```
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
For colindex As Integer = 0 To resultDt.Columns.Count - 1
|
190
|
+
|
191
|
+
```
|
192
|
+
|
193
|
+
```
|
194
|
+
|
195
|
+
Console.Write(resultDt.Rows(rowindex).Item(colindex).ToString & " ")
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
Next
|
202
|
+
|
203
|
+
```
|
204
|
+
|
205
|
+
```
|
206
|
+
|
207
|
+
Console.WriteLine()
|
208
|
+
|
209
|
+
```
|
210
|
+
|
211
|
+
```
|
212
|
+
|
213
|
+
Next
|
214
|
+
|
215
|
+
```
|
216
|
+
|
217
|
+
```
|
218
|
+
|
219
|
+
End Sub
|
220
|
+
|
221
|
+
```
|
222
|
+
|
223
|
+
```
|
224
|
+
|
225
|
+
End Class
|
226
|
+
|
227
|
+
```
|
110
228
|
|
111
229
|
|
112
230
|
|
3
ダブルクォートを追加いたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,101 +12,101 @@
|
|
12
12
|
|
13
13
|
該当のソースコード
|
14
14
|
|
15
|
-
```Public Class frmConnectAccessDB
|
16
15
|
|
16
|
+
|
17
|
+
```Public Class frmConnectAccessDB```
|
18
|
+
|
17
|
-
|
19
|
+
```Private Sub frmConnectAccessDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load```
|
18
20
|
|
19
21
|
|
20
22
|
|
21
23
|
'SQL作成
|
22
24
|
|
23
|
-
|
25
|
+
```Dim resultDt As New DataTable```
|
24
26
|
|
25
|
-
|
27
|
+
```Dim sql = New System.Text.StringBuilder()```
|
26
28
|
|
27
|
-
|
29
|
+
```sql.AppendLine("SELECT")```
|
28
30
|
|
29
|
-
|
31
|
+
```sql.AppendLine(" *")```
|
30
32
|
|
31
|
-
|
33
|
+
```sql.AppendLine("FROM ID給料")```
|
32
34
|
|
33
35
|
|
34
36
|
|
35
37
|
'Access接続準備
|
36
38
|
|
37
|
-
|
39
|
+
```Dim command As New OleDbCommand```
|
38
40
|
|
39
|
-
|
41
|
+
```Dim da As New OleDbDataAdapter```
|
40
42
|
|
41
|
-
|
43
|
+
```Dim cnAccess As OleDbConnection = New OleDbConnection```
|
42
44
|
|
43
|
-
|
45
|
+
cnAccess.ConnectionString = My.Settings.アクセス```
|
44
46
|
|
45
47
|
|
46
48
|
|
47
49
|
'Access接続開始
|
48
50
|
|
49
|
-
|
51
|
+
```cnAccess.Open()```
|
50
52
|
|
51
53
|
|
52
54
|
|
53
|
-
|
55
|
+
```Try```
|
54
56
|
|
55
57
|
|
56
58
|
|
57
|
-
command.Connection = cnAccess
|
59
|
+
```command.Connection = cnAccess```
|
58
60
|
|
59
|
-
command.CommandText = sql.ToString
|
61
|
+
```command.CommandText = sql.ToString```
|
60
62
|
|
61
|
-
da.SelectCommand = command
|
63
|
+
```da.SelectCommand = command```
|
62
64
|
|
63
65
|
|
64
66
|
|
65
67
|
'SQL実行 結果をデータテーブルに格納
|
66
68
|
|
67
|
-
da.Fill(resultDt)
|
69
|
+
```da.Fill(resultDt)```
|
68
70
|
|
69
71
|
|
70
72
|
|
71
73
|
|
72
74
|
|
73
|
-
Catch ex As Exception
|
75
|
+
```Catch ex As Exception```
|
74
76
|
|
75
|
-
Throw
|
77
|
+
```Throw```
|
76
78
|
|
77
|
-
Finally
|
79
|
+
```Finally
|
78
80
|
|
79
81
|
command.Dispose()
|
80
82
|
|
81
83
|
da.Dispose()
|
82
84
|
|
83
|
-
cnAccess.Close()
|
85
|
+
cnAccess.Close()```
|
84
86
|
|
85
|
-
End Try
|
87
|
+
```End Try```
|
86
88
|
|
87
89
|
|
88
90
|
|
89
91
|
'データテーブルの結果を表示
|
90
92
|
|
91
|
-
For rowindex As Integer = 0 To resultDt.Rows.Count - 1
|
93
|
+
```For rowindex As Integer = 0 To resultDt.Rows.Count - 1```
|
92
94
|
|
93
|
-
|
95
|
+
```For colindex As Integer = 0 To resultDt.Columns.Count - 1```
|
94
96
|
|
95
|
-
|
97
|
+
```Console.Write(resultDt.Rows(rowindex).Item(colindex).ToString & " ")```
|
96
98
|
|
97
|
-
|
99
|
+
```Next```
|
98
100
|
|
99
|
-
Console.WriteLine()
|
101
|
+
```Console.WriteLine()```
|
100
102
|
|
101
|
-
Next
|
103
|
+
```Next```
|
102
104
|
|
103
105
|
|
104
106
|
|
105
|
-
End Sub
|
107
|
+
```End Sub```
|
106
108
|
|
107
|
-
End Class```
|
109
|
+
```End Class```
|
108
|
-
|
109
|
-
|
110
110
|
|
111
111
|
|
112
112
|
|
2
ダブルクォートを追加いたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,99 +12,101 @@
|
|
12
12
|
|
13
13
|
該当のソースコード
|
14
14
|
|
15
|
-
|
15
|
+
```Public Class frmConnectAccessDB
|
16
16
|
|
17
|
-
|
17
|
+
Private Sub frmConnectAccessDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
18
18
|
|
19
19
|
|
20
20
|
|
21
21
|
'SQL作成
|
22
22
|
|
23
|
-
|
23
|
+
Dim resultDt As New DataTable
|
24
24
|
|
25
|
-
|
25
|
+
Dim sql = New System.Text.StringBuilder()
|
26
26
|
|
27
|
-
|
27
|
+
sql.AppendLine("SELECT")
|
28
28
|
|
29
|
-
|
29
|
+
sql.AppendLine(" *")
|
30
30
|
|
31
|
-
|
31
|
+
sql.AppendLine("FROM ID給料")
|
32
32
|
|
33
33
|
|
34
34
|
|
35
35
|
'Access接続準備
|
36
36
|
|
37
|
-
|
37
|
+
Dim command As New OleDbCommand
|
38
38
|
|
39
|
-
|
39
|
+
Dim da As New OleDbDataAdapter
|
40
40
|
|
41
|
-
|
41
|
+
Dim cnAccess As OleDbConnection = New OleDbConnection
|
42
42
|
|
43
|
-
cnAccess.ConnectionString = My.Settings.アクセス
|
43
|
+
cnAccess.ConnectionString = My.Settings.アクセス
|
44
44
|
|
45
45
|
|
46
46
|
|
47
47
|
'Access接続開始
|
48
48
|
|
49
|
-
|
49
|
+
cnAccess.Open()
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
-
|
53
|
+
Try
|
54
54
|
|
55
55
|
|
56
56
|
|
57
|
-
|
57
|
+
command.Connection = cnAccess
|
58
58
|
|
59
|
-
|
59
|
+
command.CommandText = sql.ToString
|
60
60
|
|
61
|
-
|
61
|
+
da.SelectCommand = command
|
62
62
|
|
63
63
|
|
64
64
|
|
65
65
|
'SQL実行 結果をデータテーブルに格納
|
66
66
|
|
67
|
-
|
67
|
+
da.Fill(resultDt)
|
68
68
|
|
69
69
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
-
|
73
|
+
Catch ex As Exception
|
74
74
|
|
75
|
-
|
75
|
+
Throw
|
76
76
|
|
77
|
-
|
77
|
+
Finally
|
78
78
|
|
79
|
-
|
79
|
+
command.Dispose()
|
80
80
|
|
81
|
-
|
81
|
+
da.Dispose()
|
82
82
|
|
83
|
-
|
83
|
+
cnAccess.Close()
|
84
84
|
|
85
|
-
|
85
|
+
End Try
|
86
86
|
|
87
87
|
|
88
88
|
|
89
89
|
'データテーブルの結果を表示
|
90
90
|
|
91
|
-
|
91
|
+
For rowindex As Integer = 0 To resultDt.Rows.Count - 1
|
92
92
|
|
93
|
-
|
93
|
+
For colindex As Integer = 0 To resultDt.Columns.Count - 1
|
94
94
|
|
95
|
-
|
95
|
+
Console.Write(resultDt.Rows(rowindex).Item(colindex).ToString & " ")
|
96
96
|
|
97
|
-
|
97
|
+
Next
|
98
98
|
|
99
|
-
|
99
|
+
Console.WriteLine()
|
100
100
|
|
101
|
-
|
101
|
+
Next
|
102
102
|
|
103
103
|
|
104
104
|
|
105
|
-
|
105
|
+
End Sub
|
106
106
|
|
107
|
-
|
107
|
+
End Class```
|
108
|
+
|
109
|
+
|
108
110
|
|
109
111
|
|
110
112
|
|
1
コードにバッククォートを追加いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,99 +12,99 @@
|
|
12
12
|
|
13
13
|
該当のソースコード
|
14
14
|
|
15
|
-
Public Class frmConnectAccessDB
|
15
|
+
```Public Class frmConnectAccessDB```
|
16
16
|
|
17
|
-
Private Sub frmConnectAccessDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
17
|
+
```Private Sub frmConnectAccessDB_Load(sender As Object, e As EventArgs) Handles MyBase.Load```
|
18
18
|
|
19
19
|
|
20
20
|
|
21
21
|
'SQL作成
|
22
22
|
|
23
|
-
Dim resultDt As New DataTable
|
23
|
+
```Dim resultDt As New DataTable```
|
24
24
|
|
25
|
-
Dim sql = New System.Text.StringBuilder()
|
25
|
+
```Dim sql = New System.Text.StringBuilder()```
|
26
26
|
|
27
|
-
sql.AppendLine("SELECT")
|
27
|
+
```sql.AppendLine("SELECT")```
|
28
28
|
|
29
|
-
sql.AppendLine(" *")
|
29
|
+
```sql.AppendLine(" *")```
|
30
30
|
|
31
|
-
sql.AppendLine("FROM ID給料")
|
31
|
+
```sql.AppendLine("FROM ID給料")```
|
32
32
|
|
33
33
|
|
34
34
|
|
35
35
|
'Access接続準備
|
36
36
|
|
37
|
-
Dim command As New OleDbCommand
|
37
|
+
```Dim command As New OleDbCommand```
|
38
38
|
|
39
|
-
Dim da As New OleDbDataAdapter
|
39
|
+
```Dim da As New OleDbDataAdapter```
|
40
40
|
|
41
|
-
Dim cnAccess As OleDbConnection = New OleDbConnection
|
41
|
+
```Dim cnAccess As OleDbConnection = New OleDbConnection
|
42
42
|
|
43
|
-
cnAccess.ConnectionString = My.Settings.アクセス
|
43
|
+
cnAccess.ConnectionString = My.Settings.アクセス```
|
44
44
|
|
45
45
|
|
46
46
|
|
47
47
|
'Access接続開始
|
48
48
|
|
49
|
-
cnAccess.Open()
|
49
|
+
```cnAccess.Open()```
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
-
Try
|
53
|
+
```Try```
|
54
54
|
|
55
55
|
|
56
56
|
|
57
|
-
command.Connection = cnAccess
|
57
|
+
```command.Connection = cnAccess```
|
58
58
|
|
59
|
-
command.CommandText = sql.ToString
|
59
|
+
```command.CommandText = sql.ToString```
|
60
60
|
|
61
|
-
da.SelectCommand = command
|
61
|
+
```da.SelectCommand = command```
|
62
62
|
|
63
63
|
|
64
64
|
|
65
65
|
'SQL実行 結果をデータテーブルに格納
|
66
66
|
|
67
|
-
da.Fill(resultDt)
|
67
|
+
```da.Fill(resultDt)```
|
68
68
|
|
69
69
|
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
-
Catch ex As Exception
|
73
|
+
```Catch ex As Exception```
|
74
74
|
|
75
|
-
Throw
|
75
|
+
```Throw```
|
76
76
|
|
77
|
-
Finally
|
77
|
+
```Finally```
|
78
78
|
|
79
|
-
command.Dispose()
|
79
|
+
```command.Dispose()```
|
80
80
|
|
81
|
-
da.Dispose()
|
81
|
+
```da.Dispose()```
|
82
82
|
|
83
|
-
cnAccess.Close()
|
83
|
+
```cnAccess.Close()```
|
84
84
|
|
85
|
-
End Try
|
85
|
+
```End Try```
|
86
86
|
|
87
87
|
|
88
88
|
|
89
89
|
'データテーブルの結果を表示
|
90
90
|
|
91
|
-
For rowindex As Integer = 0 To resultDt.Rows.Count - 1
|
91
|
+
```For rowindex As Integer = 0 To resultDt.Rows.Count - 1```
|
92
92
|
|
93
|
-
|
93
|
+
```For colindex As Integer = 0 To resultDt.Columns.Count - 1```
|
94
94
|
|
95
|
-
|
95
|
+
```Console.Write(resultDt.Rows(rowindex).Item(colindex).ToString & " ")```
|
96
96
|
|
97
|
-
Next
|
97
|
+
```Next```
|
98
98
|
|
99
|
-
Console.WriteLine()
|
99
|
+
```Console.WriteLine()```
|
100
100
|
|
101
|
-
Next
|
101
|
+
```Next```
|
102
102
|
|
103
103
|
|
104
104
|
|
105
|
-
End Sub
|
105
|
+
```End Sub```
|
106
106
|
|
107
|
-
End Class
|
107
|
+
```End Class```
|
108
108
|
|
109
109
|
|
110
110
|
|