2010-12-29 5 views
0

Access 2003 .mdb 데이터베이스에 데이터를 삽입하는 동안 문제가 있습니다. This solution 나를 위해 작동하지 않습니다!여러 단계 OLE DB 작업에서 오류가 발생했습니다.

예외 :

여러 단계 OLE DB 작업을 생성 된 오류. 가능한 경우 각 OLE DB 상태 값을 확인하십시오. No work 작업이 완료되었습니다.

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

당신은 쿼리에 잘못된 값을 전달하고

관련 문제