C#でINSERTを使っています。
以下のコードで実行していて、エラーメッセージは何も出ず、Finishedメソッドも正常に呼ばれているので、ちゃんとできていると思ってデータベースを確認すると、何も値が入っていないようです。
CREATE TABLEで実行したときは、ちゃんとMicrosoft SQL Server Management Studuioのオブジェクトエクスプローラーに表示されたのでわかりやすいですが、値はどうやって確認するのかわかりませんでした。
C#
1var connectionString = @"Persist Security Info=False;Integrated Security=true;Initial Catalog=LotoLotte;Server=MYCOMPUTER\SQLOTFTPRESS"; 2 3using (var connection = new SqlConnection(connectionString)) 4using (var command = connection.CreateCommand()) 5{ 6 try 7 { 8 connection.Open(); 9 10 //command.CommandText = @"CREATE TABLE Loto6Lottery (番号1 int, 番号2 int, 番号3 int, 番号4 int, 番号5 int, 番号6 int)"; 11 command.CommandText = @"INSERT INTO Loto6Lottery (番号1, 番号2, 番号3, 番号4, 番号5, 番号6) VALUES (" + SaveStrings() + ")"; 12 Console.WriteLine(command.CommandText); 13 14 command.ExecuteNonQuery(); 15 } 16 catch (Exception exception) 17 { 18 Console.WriteLine(exception.Message); 19 throw; 20 } 21 finally 22 { 23 connection.Close(); 24 Finished(); 25 } 26}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。