質問編集履歴

1

a

2022/10/13 07:23

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -28,16 +28,41 @@
28
28
  ### 該当のソースコード
29
29
  Controller
30
30
  ```C#
31
- public ViewResult Index(animal model )
31
+ public ViewResult Index(animal model )
32
32
  {
33
33
  DataBase1 data = new DataBase1();
34
34
 
35
+ string ConnectionStr
36
+ = ConfigurationManager.ConnectionStrings["iPentecDBConnectionString"].ConnectionString;
37
+
38
+ SqlConnection connection;
39
+ connection = new SqlConnection(ConnectionStr);
40
+
35
41
  connection.Open();
42
+
36
43
  SqlCommand command = connection.CreateCommand();
37
44
  command.CommandType = CommandType.Text;
38
45
 
46
+ command.CommandText = "SELECT ・・・";
39
47
 
48
+      //DataTableに設定
49
+      //modelListの作成
50
+ return View(model);
51
+ }
52
+
53
+ [HttpGet]
54
+ public ActionResult Create()
55
+ {
56
+ return View();
57
+ }
58
+ [HttpPost]
40
- command.CommandText = "SELECT ・・・";
59
+ public ActionResult Create(String id2)
60
+ {
61
+ //データベース接続
62
+     //SELECT文
63
+ return View(model);
64
+ }
65
+
41
66
  ```
42
67
 
43
68
  ### 試したこと