すでにこれらの投稿がたくさんあることは知っていますが、私はそれらの多くを調べましたが、それらはすべて特定の人のニーズに固有のものであるように思われるので、誰かが私の特定のニーズに対して私を助けてくれるかどうかを知りたいと思いました.
Oledb と c# を使用しており、Excel ワークシートを作成して入力しようとしていますが、この INSERT ステートメントを使用すると、「クエリ式に構文エラー (演算子がありません)」というエラーが表示されます。
for (int i = 0; i <= 20; i++)
{
command.CommandText = string.Format("INSERT INTO [Table] (Id, Tag, Description) VALUES ('{0}','2','3')", diff1[i]);
command.ExecuteNonQuery();
}
説明すると、文字列の配列 diff1[] があり、ループを使用して各要素を独自のセルに挿入しています。文字列要素に到達するまで機能します。
"\r\n\"603\",\"FuelPumpTestWarning\",\"<table style=\"\"border: 4px solid black; border-collapse:collapse;\"\">\r\n<tbody>\r\n<tr>\r\n<td bgcolor=\"\"#FF7700\"\" style=\"\"border: 5px solid black; border-collapse:collapse;\"\">\r\n<div style=\"\"width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent; border-bottom: 33px solid black; margin: 5px 5px 5px 5px;\"\" >\r\n<p style=\"\"font-family:Arial; color:#ff7700; \r\nfont-size:32px; margin:5px -5px 0px -5px;\"\">!</p>\r\n<p style=\"\"color:black; font-size:32px; margin:-45px 30px; font-family:'Arial Black', Arial; font-weight:'900';\"\">WARNING</p>\r\n</div>\r\n</td>\r\n</tr>\r\n<tr>\r\n<td style=\"\"border: 5px solid black; border-collapse:collapse;\"\">\r\n<p style=\"\"font-size:12px; font-family:'Arial Black', Arial; font-weight:'900'\"\">You are about to perform a test that\r\ninvolves pressurized gasoline being\r\npumped. Before performing this\r\ntest, be sure the area is free and\r\nclear from combustibles, open\r\nflame, welding and/or grinding\r\nsparks, or anything else that could\r\nignite or be an ignition source.<br>\r\n<br>\r\nFAILURE TO FOLLOW THIS WARNING\r\nMAY CAUSE INADVERTENT IGNITION\r\nTHAT COULD RESULT IN SERIOUS\r\nINJURY OR DEATH.</p>\r\n</td>\r\n</tr>\r\n</tbody>\r\n</table>\""
最後の 2 つの列が 2 と 3 で埋められているという事実は無視してください。これは、文字列の配列を使用して埋められるため、これを行う方法がわかるまでの単なるプレースホルダーです。エラーが発生している文字列要素に特殊文字はありますか? これに似た他の約 10 個の要素を通過しますが、この要素ではエラーが発生します。
考えられるすべてのオプションを使い果たしたので、どんな助けも大歓迎です。