2012-04-27 4 views
1

내 액세스 데이터베이스를 업데이트해야이 코드를 가지고,하지만 난라는 오류가 계속 :Visual Basic에서 2010 오류

테이블 때문에 regists을 변경하거나 삭제할 그렇게 할 수 없습니다 'MembrosCompasso'에 관련된 레코드가 있습니다.

Dim query1 As String = "UPDATE MembrosCompasso SET [email protected]_bi WHERE MembrosCompasso.BI=Membros.BI" ' [email protected], Membros.Mae=mae WHERE [email protected]" 
Dim query As String = "UPDATE Membros SET [email protected]_bi, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] WHERE [email protected]" 

con.Close() 
con.Open() 
Dim command As New OleDbCommand(query, con) 
Dim command1 As New OleDbCommand(query1, con) 
' Indicação dos parâmetros que serão actualizados 

command1.Parameters.Add("@compass_bi", OleDbType.VarChar).Value = BI.Text 
command.Parameters.Add("@num_bi", OleDbType.VarChar).Value = BI.Text 
command.Parameters.Add("@nome", OleDbType.VarChar).Value = Nome.Text 
command.Parameters.Add("@hablitacoes", OleDbType.VarChar).Value = hablitacoes.Text 
command.Parameters.Add("@contribuinte", OleDbType.VarChar).Value = ncront.Text 
command.Parameters.Add("@telemov", OleDbType.VarChar).Value = telmov.Text 
command.Parameters.Add("@natnasc", OleDbType.VarChar).Value = datnasc.Text 
command.Parameters.Add("@localnasc", OleDbType.VarChar).Value = NascLocal.Text 
command.Parameters.Add("@databapt", OleDbType.VarChar).Value = DataBapt.Text 
command.Parameters.Add("@localbapt", OleDbType.VarChar).Value = LocalBapt.Text 
command.Parameters.Add("@sexo", OleDbType.VarChar).Value = sexo.Text 
command.Parameters.Add("@natu", OleDbType.VarChar).Value = natu.Text 
command.Parameters.Add("@prof", OleDbType.VarChar).Value = profi.Text 
command.Parameters.Add("@estadciv", OleDbType.VarChar).Value = estciv.Text 
command.Parameters.Add("@datacas", OleDbType.VarChar).Value = datcas.Text 
command.Parameters.Add("@localcas", OleDbType.VarChar).Value = localcas.Text 
command.Parameters.Add("@notas", OleDbType.VarChar).Value = notas.Text 
command.Parameters.Add("@email", OleDbType.VarChar).Value = email.Text 
command.Parameters.Add("@BI", OleDbType.VarChar).Value = numero_BI 

내 액세스 DB 스키마 here의 스크린 샷이 있습니다 :

내 코드입니다.

답변

1

Membros 테이블을 변경하기 전에 MembrosCompasso 테이블을 업데이트하는 것처럼 보입니다.
MembrosCompasso.BIMembros.BI과 관련이 있으므로이 테이블에 먼저 있어야합니다.

Access에서 관계를 자동으로 업데이트하도록 설정하면 MembrosCompasso으로 수동 업데이트를 수행 할 필요가 없으며 원본 필드를 업데이트 할 때 자동으로 업데이트됩니다.

예를 들어 POItem이 많은 PO 테이블이 있다고 가정 해 보겠습니다. 내가 PO.ID를 업데이트 할 경우 모든 POItem.POID 필드가 업데이트됩니다,이 경우

enter image description here

:
나는 다음과 같이 그들 사이의 일대 다 관계를 설정할 수 있습니다.
동일한레코드를 삭제하면 관련된 모든 POItem 레코드도 삭제됩니다.

MS Access documentation about table relationships을 살펴보십시오.

+0

thanx 문제가있는 – user1341926