Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Private Sub insert()Dim status As Stringstatus = CboStaAlun.ListIndexDim codbai As StringDim codcid As StringDim coduf As StringWith TB.Open "Select CodBairro from TabBairro where NomBairro='" & TxtBairro.Text & "'", BD If .EOF Then .Close BD.Execute "Insert into TabBairro (NomBairro) values ('" & TxtBairro.Text & "')" .Open "Select CodBairro from TabBairro where NomBairro='" & TxtBairro.Text & "'", BD codbai = TB("CodBairro") .Close Else codbai = TB("CodBairro") .Close End IfEnd With With TB.Open "Select CodCidade from TabCidade where Cidade='" & TxtCidade.Text & "'", BD If .EOF Then .Close BD.Execute "Insert into TabCidade (Cidade) values ('" & TxtCidade.Text & "')" .Open "Select CodCidade from TabCidade where Cidade='" & TxtCidade.Text & "'", BD codcid = TB("CodCidade") .Close Else codcid = TB("CodCidade") .Close End IfEnd WithWith TB .Open "Select CodStatus from TabStatusAlun where Status='" & CboStaAlun.Text & "'", BD status = TB!CodStatus .CloseEnd WithWith TB.Open "Select CodEstado from TabEstado where SiglaEstado='" & CboUF.Text & "'", BDcoduf = TB("CodEstado").CloseEnd With If insertdata = True Then Dim teste As Stringsql = "Insert Into TabAlun (NascAlun, NomAlun, CEPAlun, NumEndAlun, CodStatus, EmailAlun, PaiAlun, NascPaiAlun, ProfPaiAlun, JobPaiAlun, MaeAlun, NascMaeAlun, ProfMaeAlun, JobMaeAlun, DDDTelAlun, TelAlun, DDDCelAlun, CelAlun, DDDTelPai, TelPai, DDDTelMae, TelMae, RgAlun, CpfAlun) VALUES (" & TxtNascAlun.Text & ",'" & TxtNomAlun.Text & "'," & TxtCep.Text & "," & TxtNumAlun.Text & "," & status & ",'" & TxtEmailAlun.Text & "','" & TxtNomPai.Text & "'," & TxtNascPai.Text & ",'" & TxtProfPai.Text & "','" & TxtJobPai.Text & "','" & TxtNomMae.Text & "'," & TxtNascMae.Text & ",'" & TxtProfMae.Text & "','" & TxtJobMae.Text & "'," & TxtDddTelAlun.Text & "," & TxtTelAlun.Text & "," & TxtDddCelAlun.Text & "," & TxtCelAlun.Text & "," & TxtDddTelPai.Text & "," & TxtTelPai.Text & "," & TxtDddTelMae & "," & TxtTelMae & "," & TxtRgAlun.Text & "," & TxtCpfAlun.Text & ")" BD.Execute sqlTB.Open "Select CEP from TabCep where CEP ='" & TxtCep.Text & "'", BD If TB.EOF Then TB.Close BD.Execute "Insert into TabCep (CEP, NomRua, Bairro, Cidade, Estado) values (" & TxtCep.Text & "," & TxtEnd.Text & "," & codbai & "," & codcid & "," & coduf & ")" End If MsgBox "Seu registro foi incluído com sucesso!", 64, "Aviso" Call Enable_cmd(CadAlun, True) Call Enable_frm(CadAlun, False) Call Clear_frm(CadAlun) Else BD.Execute "" End If End SubO que ta rolando aqui é o seguinte,
Estou fazendo uma inclusão de uma novo aluno na tabela, porém não coloco as infos de endereço deste aluno, com exceção do número da casa e do CEP. Assim eu consigo optimizar meu banco aproveitando O CEP em outros registros. Pois bem, relacionaei o CEP do aluno ao CEP da tabela de cep, agora quando eu vou fazer a inclusão ocorre um erro de relacionamento.
/applications/core/interface/imageproxy/imageproxy.php?img=http://www.guiadecorretores.com.br/downs/erro.jpg&key=6d2a6b14b9af6f81ea06fbe61d26151a16d537f7460e0d3d37b4a03c8a1f5e41" alt="Imagem Postada" />
COMO FAÇO PRA SOLUCIONAR ISSO??? É MUITO URGENTE!!!
Outra coisa, eu gostaria que alguns destes campos estivessem vazios, ja que não são de preenchimento obrigatório. Porém quando eles estão vazios da erro de sintaxe.
Aguardo uma luz....
Carregando comentários...