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

質問編集履歴

2

個人情報の削除

2022/12/12 11:44

投稿

popomo
popomo

スコア3

title CHANGED
File without changes
body CHANGED
@@ -61,10 +61,10 @@
61
61
  try
62
62
  {
63
63
  SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
64
- builder.DataSource = "(local)";
64
+ builder.DataSource = "";
65
65
  builder.InitialCatalog = "";
66
- builder.UserID = "sa";
66
+ builder.UserID = "";
67
- builder.Password = "0302";
67
+ builder.Password = "";
68
68
 
69
69
  Console.WriteLine("builder.ConnectionString");
70
70
  con.ConnectionString = builder.ConnectionString;

1

気になる部分を追記

2022/12/12 11:37

投稿

popomo
popomo

スコア3

title CHANGED
File without changes
body CHANGED
@@ -12,7 +12,22 @@
12
12
  ### 発生している問題・エラーメッセージ
13
13
 
14
14
  ```
15
- 特になし
15
+ 特になしですが,下記の部分が個人的に間違っているのかと思います。
16
+
17
+ SqlCommand cmd = new SqlCommand("SELECT * FROM Table_1;", con);
18
+ SqlDataReader reader = cmd.ExecuteReader();
19
+
20
+ using (var sw = new System.IO.StreamWriter(@"C:\test\test.csv", false))
21
+ while (reader.Read())
22
+ {
23
+ //DBからデータを取得
24
+ ID = reader.GetValue(0).ToString();
25
+ FirstName = reader.GetValue(1).ToString();
26
+ LastName = reader.GetValue(2).ToString();
27
+ Birthday = reader.GetValue(3).ToString();
28
+ Gender = reader.GetValue(4).ToString();
29
+ Money = reader.GetValue(5).ToString();
30
+
16
31
  ```
17
32
 
18
33
  ### 該当のソースコード