2014-03-12 2 views
-1

시스템이 업데이트되지 않고이 오류가 표시됩니다. 어떻게해야할지 모르겠습니다. 어떤 제안?데이터베이스 업데이트 쿼리에 오류가 발생했습니다.

com.Connection = con; 

을하고 그들이 가지고있는 값을 확인하려면 이동으로 각 변수를 검사하여 코드를 단계별로 : 다음 줄에 중단 점을 넣어 내 코드

private void btnupdate_Click(object sender, EventArgs e) 
    { 
     com.Connection = con; 
     con.Open(); 


     string query = "UPDATE [Promissory] SET [pdate] = ?,[Edpno] = ?, [gradingperiod] = ?, [pamount] = ?, [reasons] = ?, [syid] = ? WHERE Promissoryno = ?"; 

     var accessUpdateCommand = new OleDbCommand(query, con); 
     accessUpdateCommand.Parameters.AddWithValue("pdate", txtdate.Text); 
     accessUpdateCommand.Parameters.AddWithValue("Edpno", txtedpno.Text); 
     accessUpdateCommand.Parameters.AddWithValue("gradingperiod", txtgradeperiod.Text); 
     accessUpdateCommand.Parameters.AddWithValue("pamount", txtamount.Text); 
     accessUpdateCommand.Parameters.AddWithValue("reasons", txtreasons.Text); 
     accessUpdateCommand.Parameters.AddWithValue("syid", txtsyid.Text); 

     accessUpdateCommand.Parameters.AddWithValue("Promissoryno", txtpromiseno.Text); // Replace "123" with the variable where your ID is stored. Maybe row[0] ? 
     da.UpdateCommand = accessUpdateCommand; //This line here is the error 
     da.UpdateCommand.ExecuteNonQuery(); 


     con.Close(); 
} 
+0

정확히 어떤 오류가 있습니까? –

+0

오류가 발생한 행은 무엇입니까? –

+2

'com','con' 또는'da' 변수 중 적어도 하나는 null입니다. 메서드의 첫 번째 줄에 중단 점을 설정하고 모두 체크하십시오. – Viper

답변

0

입니다. 그 중 하나는 null입니다. 뭔가 초기화되지 않았거나 범위를 벗어나 처리 중입니다.

관련 문제