Ajuda para encontrar erro

1 resposta
P
tenho uma matriz que recebe o id e a disciplina de uma certa tabela no banco,depois ao fazer ao editar certos valores que quero armazenar novamente no banco eu edito todos ao inves de editar so um. Por ex:no banco eu tenho
tabela nota
id|disciplina|modulo|atividade|nota|rc_aluno
 1 |biologia|  1       |  teste    | 6.3 |      2   
2  |biologia|  1       |prova     |5.6  |     2
tipo se eu tento trocar o campo atividade onde diz teste por trabalho,eu troco prova por trabalho tambem =[ eis o codigo
if(b[i].getText()!=null)
							{
								//cria uma matriz cm id e a atividade
								System.out.println("select Id,atividade from nota where rc_aluno='"+t0.getText()+"' and disciplina='"+k+"' and modulo='"+k1+"'");
								resultado=comando.executeQuery("select Id,atividade from nota where rc_aluno='"+t0.getText()+"' and disciplina='"+k+"' and modulo='"+k1+"'");// and atividade='"+""+"'
								while (resultado.next())
								{ 
									m[q][0]=resultado.getObject(1).toString();//c tam m<50 ocorre arrayindexout troca o txt dos os botoes
									m[q][1]=resultado.getObject(2).toString();
									q++;
									System.out.println("valor d q "+q);
								}
								for(int j=0;j<m[i].length;j++)
								{
									System.out.println("UPDATE nota SET nota ='"+t5.getText()+"',atividade ='"+b[i].getText()+"' WHERE rc_aluno='"+t0.getText()+"' and disciplina='"+k+"' and modulo='"+k1+"' and Id ='"+m[j][0]+"' ");
									if(m[j][0]!=null && m[j][1]!=null)
										comando.executeUpdate("UPDATE nota SET nota ='"+t5.getText()+"',atividade ='"+b[i].getText()+"' WHERE rc_aluno='"+t0.getText()+"' and disciplina='"+k+"' and modulo='"+k1+"' and Id ='"+m[j][0]+"' ");   
									System.out.println("id "+m[j][0]+" disc "+m[j][1]+" b[i] "+b[i].getText());
								}

							}
podem me ajudar a encontrar o erro? obrigada

1 Resposta

P
tentei fazer assim so pesquisando o id sem usar matriz mas o problema é que só altera o primeiro campo que eu mudei,segue o cod
if(b[i].getText()!=null)
							{
								//cria uma matriz cm id e a atividade
								System.out.println("select Id from nota where rc_aluno='"+t0.getText()+"' and disciplina='"+k+"' and modulo='"+k1+"'");
								resultado=comando.executeQuery("select Id from nota where rc_aluno='"+t0.getText()+"' and disciplina='"+k+"' and modulo='"+k1+"'");// and atividade='"+""+"'
								while (resultado.next())
								{ 
									pk=resultado.getObject(1).toString();
								}
								for(int j=0;j<m[i].length;j++)
								{
									System.out.println("UPDATE nota SET nota ='"+t5.getText()+"',atividade ='"+b[i].getText()+"' WHERE rc_aluno='"+t0.getText()+"' and disciplina='"+k+"' and modulo='"+k1+"' and Id ='"+pk+"' ");
									
										comando.executeUpdate("UPDATE nota SET nota ='"+t5.getText()+"',atividade ='"+b[i].getText()+"' WHERE rc_aluno='"+t0.getText()+"' and disciplina='"+k+"' and modulo='"+k1+"' and Id ='"+pk+"' ");   
									
								}

							}
obg
Criado 22 de janeiro de 2011
Ultima resposta 22 de jan. de 2011
Respostas 1
Participantes 1