質問編集履歴

3

コメントの追加

2017/02/03 11:04

投稿

help_
help_

スコア20

test CHANGED
File without changes
test CHANGED
@@ -41,6 +41,8 @@
41
41
  Dim tablename as string 'Table名が入っています。
42
42
 
43
43
  Dim getSchema as New DataTable
44
+
45
+ 'DBの接続を行っています。接続成功したまたは接続済みの場合にTrueを返します。
44
46
 
45
47
  If DBConnect() Then
46
48
 

2

コードの補足を行いました。

2017/02/03 11:04

投稿

help_
help_

スコア20

test CHANGED
File without changes
test CHANGED
@@ -8,11 +8,19 @@
8
8
 
9
9
 
10
10
 
11
- テーブルのカラム一覧を取得し追加したDataTable型に
11
+ テーブルのカラム一覧を取得し追加したDataTable型のPrimaryKey
12
12
 
13
- 取得したPrimaryKeyの入ったList(of DataColum)をtoArrayで追加しようとした際に
13
+ List(of DataColum)から値代入を使用としています。
14
14
 
15
+ ```VB.net
16
+
17
+ getSchema.PrimaryKey = getPrimaryKeylist(tablename).ToArray()
18
+
19
+ ```
20
+
15
- 下記エラーが発生します。
21
+ そこで下記エラーが発生します。
22
+
23
+
16
24
 
17
25
  > System.ArgumentException はユーザー コードによってハンドルされませんでした。
18
26
 
@@ -30,6 +38,8 @@
30
38
 
31
39
  ```VB.net
32
40
 
41
+ Dim tablename as string 'Table名が入っています。
42
+
33
43
  Dim getSchema as New DataTable
34
44
 
35
45
  If DBConnect() Then
@@ -45,6 +55,8 @@
45
55
  "WHERE TABLE_NAME = '" & tablename & "' " & _
46
56
 
47
57
  "Order by ORDINAL_POSITION "
58
+
59
+ 'QueryExecuteは受け取ったQueryを実行して、結果をDataTableで返します。
48
60
 
49
61
  Dim dtshema As DataTable = QueryExecuteReader(sql)
50
62
 
@@ -72,6 +84,8 @@
72
84
 
73
85
  "where table_name = '" & tableName & "' and constraint_name like 'PK_%'"
74
86
 
87
+ 'QueryExecuteは受け取ったQueryを実行して、結果をDataTableで返します。
88
+
75
89
  Dim dtPK As DataTable = QueryExecuteReader(sql)
76
90
 
77
91
  For Each rowPK As DataRow In dtPK.Rows
@@ -80,7 +94,7 @@
80
94
 
81
95
  Next ' ここでエラー発生
82
96
 
83
- getSchema.PrimaryKey = getPrimaryKeylist(tablename).ToArray()
97
+ getSchema.PrimaryKey = getPrimaryKeylist.ToArray()
84
98
 
85
99
  Else
86
100
 

1

タグの追加

2017/02/03 11:01

投稿

help_
help_

スコア20

test CHANGED
File without changes
test CHANGED
File without changes