ADO.NETを使用してExcelファイルに書き込もうとすると、構文エラーが発生します。クエリにパラメータを追加するにはどうすればよいですか。私はmysqlデータベースを更新しています。OleDbDataWriterにパラメータを追加する方法
string error="Text for status";
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=Excel 12.0;";
System.Data.OleDb.OleDbConnection ExcelConnection = new System.Data.OleDb.OleDbConnection(connectionString);
string ExcelQuery;
ExcelQuery = "Update [Sheet1$] set Status="+error; // from Sheet1";
//Create the command to be executed
ExcelCommand = new System.Data.OleDb.OleDbCommand(ExcelQuery, ExcelConnection);
//Open the connection to the file
ExcelConnection.Open();
//Execute the update
ExcelCommand.ExecuteNonQuery();
//Close the connection
ExcelConnection.Close();
構文エラー ' 状態のテキスト' クエリ式内(演算子がありません)。
Excelのステータス列を文字列エラーで更新しています。パラメータを追加する必要がありますか?パラメータなしで行うことができますか? – Murthy