質問編集履歴
3
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
```C#
|
16
16
|
|
17
|
-
//
|
17
|
+
//1
|
18
18
|
|
19
19
|
if (result == DialogResult.Yes)
|
20
20
|
|
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
// SQLの設定
|
52
52
|
|
53
|
-
command.CommandText = "
|
53
|
+
command.CommandText = "SELECT FROM PostList where PostCode = @postCode and PostName = @postName;";
|
54
54
|
|
55
55
|
|
56
56
|
|
2
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -498,9 +498,81 @@
|
|
498
498
|
|
499
499
|
```
|
500
500
|
|
501
|
-
普通の検索は、これで、出来たのですが、
|
502
|
-
|
503
|
-
|
501
|
+
普通の検索は、これで、出来たのですが、dataAdapterをどうすれば、使えるのかが、分かりませんでした。
|
502
|
+
|
503
|
+
```
|
504
|
+
|
505
|
+
public void PostData()
|
506
|
+
|
507
|
+
{
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
// 接続文字列の取得
|
512
|
+
|
513
|
+
DBManager dBManager = new DBManager();
|
514
|
+
|
515
|
+
{
|
516
|
+
|
517
|
+
try
|
518
|
+
|
519
|
+
{
|
520
|
+
|
521
|
+
DataTable dt = new DataTable();
|
522
|
+
|
523
|
+
// データベースの接続開始
|
524
|
+
|
525
|
+
dBManager.BeginTran();
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
// SQLの設定
|
530
|
+
|
531
|
+
String selectSql = "Select * From PostList order by CONVERT (int,PostCode);";
|
532
|
+
|
533
|
+
SqlDataReader reader = dBManager.ExecuteQuery(selectSql);
|
534
|
+
|
535
|
+
// SQLの実行
|
536
|
+
|
537
|
+
SqlDataAdapter sda = new SqlDataAdapter(command);
|
538
|
+
|
539
|
+
sda.Fill(dt);
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
dataGridView1.DataSource = dt;
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
}
|
548
|
+
|
549
|
+
catch (Exception exception)
|
550
|
+
|
551
|
+
{
|
552
|
+
|
553
|
+
MessageBox.Show("異常終了" + exception.Message);
|
554
|
+
|
555
|
+
}
|
556
|
+
|
557
|
+
finally
|
558
|
+
|
559
|
+
{
|
560
|
+
|
561
|
+
// データベースの接続終了
|
562
|
+
|
563
|
+
dBManager.Close();
|
564
|
+
|
565
|
+
}
|
566
|
+
|
567
|
+
}
|
568
|
+
|
569
|
+
}
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
```
|
574
|
+
|
575
|
+
上のコードでは、SqlDataAdapter sda = new SqlDataAdapter(command);でcommandがないので、エラーが起こります。どうすればいいでしょうか。
|
504
576
|
|
505
577
|
分かりにくい内容になってしまい、すいませんが、教えて頂きたいです。
|
506
578
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
|
13
13
|
DBと接続するために、下のように書いていました。
|
14
14
|
|
15
|
-
```
|
15
|
+
```C#
|
16
|
+
|
16
|
-
|
17
|
+
//削除
|
17
|
-
|
18
18
|
|
19
19
|
if (result == DialogResult.Yes)
|
20
20
|
|
@@ -154,7 +154,7 @@
|
|
154
154
|
|
155
155
|
|
156
156
|
|
157
|
-
```
|
157
|
+
```C#
|
158
158
|
|
159
159
|
using System;
|
160
160
|
|