2010-12-29 159 views
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; 
    } 
} 

をどんな答えずに有名な問題であるようです! !! :(

+0

注:。。 'Connection.Openは();'正常に動作します – Jalal

+0

私が試してみて、あなたの 'INSERT'のクエリはので、私は助けることができるどのようなものかを推測しますあなたは私のクリスタルボールを持っていません。 –

+0

クリスタルボールは必要ありません!私はインサート機能を追加しました!:D – Jalal

答えて

-1

クエリに間違った値を渡している

関連する問題