0
Access 2003 .mdbデータベースにデータを挿入する際に問題があります。 This solution私のためには機能しません!複数ステップのOLE DB操作でエラーが発生しました
例外:
複数ステップのOLE DB操作 生成されたエラー。可能であれば、各OLE DB ステータス値を確認します。いいえ仕事は でした。
app.config
ファイルで私の接続文字列:私のコードで
<connectionStrings>
<add name="UI.Properties.Settings.ZangolehDbConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Db\ZangolehDb.mdb;"
providerName="System.Data.OleDb" />
</connectionStrings>
...
更新日:
public static bool Insert(GlobalEvent globalEvent)
{
bool result = false;
using (OleDbConnection connection = new OleDbConnection(DataAccess.ConnectionString))
{
OleDbCommand command = connection.CreateCommand();
command.CommandText = "INSERT INTO UserEvents(Title, Comment, Volume, EventType, EventDate, MediaSource)VALUES(@Title, @Comment, @Volume, @EventType, @EventDate, @MediaSource)";
command.CommandType = CommandType.Text;
command.Parameters.AddWithValue("@Title", globalEvent.Title);
command.Parameters.AddWithValue("@Comment", globalEvent.Comment);
command.Parameters.AddWithValue("@Volume", globalEvent.Volume);
command.Parameters.AddWithValue("@EventType", globalEvent.EventType);
command.Parameters.AddWithValue("@EventDate", globalEvent.EventDate);
command.Parameters.AddWithValue("@MediaSource", globalEvent.MediaSource);
try
{
command.Connection.Open();
result = command.ExecuteNonQuery() > 0; // <-- Throws Exception...
command.Connection.Close();
}
catch { result = false; }
finally
{
command.Connection.Close();
}
return result;
}
}
をどんな答えずに有名な問題であるようです! !! :(
注:。。 'Connection.Openは();'正常に動作します – Jalal
私が試してみて、あなたの 'INSERT'のクエリはので、私は助けることができるどのようなものかを推測しますあなたは私のクリスタルボールを持っていません。 –
クリスタルボールは必要ありません!私はインサート機能を追加しました!:D – Jalal