teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

追記

2017/07/27 15:28

投稿

chintao1224
chintao1224

スコア156

title CHANGED
File without changes
body CHANGED
@@ -18,4 +18,30 @@
18
18
  dim readerのところでエラーになります。
19
19
  「Npgsql.NpgsqlException: '外部コンポーネントが例外をスローしました。'」
20
20
 
21
- コード自体間違っているのでしょうか。
21
+ コード自体間違っているのでしょうか。
22
+
23
+ ソースをまとめてみました。
24
+
25
+ ```vb.net
26
+ Dim npgCnct As NpgsqlConnection
27
+ Dim npgCmnd As NpgsqlCommand
28
+ Dim npgDR As NpgsqlDataReader
29
+ Dim strSql As String
30
+
31
+ npgCnct = New Npgsql.NpgsqlConnection
32
+ npgCnct.ConnectionString = "Server=localhost;Port=5432;User Id=user1;Password=pass;Database=TESTDB;"
33
+ npgCnct.Open()
34
+
35
+ strSql = "SELECT * FROM public.TEST;"
36
+
37
+ npgCmnd = New NpgsqlCommand
38
+ npgCmnd.Connection = npgCnct
39
+ npgCmnd.CommandText = strSql
40
+ npgDR = npgCmnd.ExecuteReader()
41
+ ```
42
+
43
+ やはりnpgDR = npgCmnd.ExecuteReader()のところで下記のエラーが出ます。
44
+
45
+ 「Npgsql.PostgresException: '外部コンポーネントが例外をスローしました。'」
46
+
47
+ なぜエラーになるのでしょうか?