2010-12-29 3 views
0

Ich habe ein Problem beim Einfügen von Daten in eine Access 2003 MDB-Datenbank. This solution funktioniert nicht für mich!Mehrstufiger OLE DB-Vorgang generierte Fehler

Ausnahme:

mehreren Schritten bestehenden OLE DB Betrieb erzeugten Fehler. Überprüfen Sie jeden OLE DB Statuswert, falls verfügbar. Keine Arbeit wurde getan.

Meine Verbindungszeichenfolge in app.config Datei:

<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> 

In meinem Code ...

AKTUALISIERT:

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; 
    } 
} 

Es scheint, dies ohne jede Antwort ein berühmtes Problem! !! :(

+0

. HINWEIS: 'Connection.Open();' funktioniert gut – Jalal

+0

Ich würde versuchen und erraten, was Ihre 'INSERT' Abfrage aussieht, so kann ich helfen. Du, aber ich habe meine Kristallkugel gerade nicht bei mir. –

+0

Du brauchst keine Kristallkugel! Ich füge die Funktion ein!: D – Jalal

Antwort

-1

Sie vorbei falsche Werte an die Abfrage

Verwandte Themen