Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Boa tarde galera...
Tô penando com um update que dá certo e errado ao mesmo tempo.
Acontece que tenho uma quantidade de registros do bd que devem ser "corrigidos" e tem uma identificação pra cada um não atualizar a linha errada do bd.... até aí beleza mas quando pego um arquivo grande dá pau.
Tem um erro no update que não consigo achar, se dou um response.write, ele mostra certinho os dados a serem atualizados, daí coloco um on error resume next e se uso um arquivo pequeno maravilha ele ignora o erro e faz o update certinho, mas se uso um arquivo grande ele dá script timeout, já tentei colocar um Server.scriptTimeout maior e não adianta, o tempo excede. Por favor deem uma olhada pq eu ja não enxergo mais o erro.
Aí embaixo está o cód das duas pgs e no bd todos os campos (menos o ID que é AutoIncremento) são tipo texto.
Página onde monta o form
'Depois de abrir a conexão e o recordset ele monta um form pra "mostrar" onde tem erros e facilitar para corrigir cont=0totalregistros=0 Do While rs.EOF = Falsecont=cont+1%> <tr> <%on error resume nextresponse.write "<tr align=""center"">"%><input type="hidden" name="id<%=cont%>" value="<%= rs("id") %>"><td > <center> <input size="5" name="apag<%=cont%>" type="checkbox" value="<%= rs("id") %>" > </center> </td> <%If IsNull(rs("tipo")) OR rs("tipo") = "0" or rs("tipo") = "" Then%> <td height="30" bgcolor=#eeeeee><span class="style2">N/D</span></td> <%Else%> <td height="30"bgcolor=#eeeeee><span class="style2"><%= rs("tipo") %></span></td> <%End IFIF IsNull(rs("entidade")) OR rs("entidade") = "0" or rs("entidade") = "" Then%> <td><span class="style2">N/D</span></td> <%Else%> <td><span class="style2"><%= rs("entidade") %></span></td> <%End IFIF IsNull(rs("matricula")) OR rs("matricula") = "0" or rs("matricula") = "" Then%> <td bgcolor=#eeeeee> <input size="5" name="matrig<%=cont%>" type="text" style="background:#D2F7DB" value ="<%= rs("matricula") %>" > </td> <%Else%> <td bgcolor=#eeeeee><input size="5" name="matrig<%=cont%>" type="text" value ="<%= rs("matricula") %>" ></td> <%End IFIF IsNull(rs("nome")) OR rs("nome") = "0" or rs("nome") = "" Then%> <td width="330"> <textarea name="nome" cols="30" rows="1"><%= rs("nome") %></textarea> </td> <%Else%> <td width="330"><textarea name="nome" cols="30" rows="1"><%= rs("nome") %></textarea></td> <%End IFIF IsNull(rs("cargo")) OR rs("cargo") = "0" or rs("cargo") = "" Then%> <td bgcolor=#eeeeee> <input type="text" name="cargo<%=cont%>" style="background:#D2F7DB" size ="10" value ="<%= rs("cargo") %>"> </td> <%Else%> <td bgcolor=#eeeeee><input type="text" name="cargo<%=cont%>" size ="10" value ="<%= rs("cargo") %>"></td> <%End IFsexo = "F"sexo2 = "M"IF IsNull(rs("sexo")) OR rs("sexo") < sexo or rs("sexo") = "" or rs("sexo") > sexo2 Then%> <td> <input type="text" name="sexo<%=cont%>" style="background:#D2F7DB" size ="3" value ="<%= rs("sexo") %>"> </td> <%Else%> <td><input type="text" name="sexo<%=cont%>" size ="3" value ="<%= rs("sexo") %>"></td> <%End IFsolt = "solteiro"ama = "amasiado"desq = "desquitado"viuv = "viuvo"divor = "divorciado"casado = "casado"IF IsNull(rs("est_civ")) or rs("est_civ") = "" or rs("est_civ") = "0" or estado(rs("est_civ")) > viuv Then%> <td bgcolor=#eeeeee> <input type="text" name="estciv<%=cont%>" style="background:#D2F7DB" size ="10" value ="<%= rs("est_civ") %>"> </td> <%Else%> <td bgcolor=#eeeeee><input type="text" name="estciv<%=cont%>" size ="10" value ="<%= estado(rs("est_civ")) %>"></td> <%End IFdata_nasc = Idade(rs("dt_nasc"))IF Isnull(rs("dt_nasc")) OR rs("dt_nasc") = "" or data_nasc < 14 or data_nasc > 100 Then%> <td> <input type="text" style="background:#D2F7DB" size ="10" name="dtnasc<%=cont%>" value ="<%=rs("dt_nasc")%>"> </td> <%Else%> <td><input type="text" size ="10" name="dtnasc<%=cont%>" value ="<%=rs("dt_nasc")%>"></td> <%End IF IF IsNull(rs("inss_ant")) OR rs("inss_ant") = "" Then%> <td bgcolor=#eeeeee> <input type="text" style="background:#D2F7DB" size ="3" name="inss<%=cont%>" value ="<%= rs("inss_ant")%>"> </td> <%Else%> <td bgcolor=#eeeeee><input type="text" size ="3" name="inss<%=cont%>" value ="<%= rs("inss_ant")%>"></td> <%End IFIF IsNull(rs("dt_rp")) OR rs("dt_rp") = "0" or rs("dt_rp") = "" Then%> <td> <input type="text" style="background:#D2F7DB" name="rp<%=cont%>" size ="10" value ="<%= rs("dt_rp") %>"> </td> <%Else%> <td><input type="text" name="rp<%=cont%>" size ="10" value ="<%= rs("dt_rp") %>"></td> <%End IFdt_adm = Dtatual(rs("dt_adm"))dt_rp = Dtatual(rs("dt_rp"))IF IsNull(rs("dt_adm")) OR rs("dt_adm") = "0" or rs("dt_adm")= "" or (data_nasc - dt_adm) < 18 or (data_nasc - dt_adm) > 70 Then%> <td bgcolor=#eeeeee> <input type="text" name="adm<%=cont%>" style="background:#D2F7DB" size ="10" value ="<%= rs("dt_adm") %>"> </td> <%Else%> <td bgcolor=#eeeeee><input type="text" name="adm<%=cont%>" size ="10" value ="<%= rs("dt_adm") %>"></td> <%End IFnorm = "N"esp = "E"IF IsNull(rs("tp_apos")) OR rs("tp_apos") = "0" or rs("tp_apos") = "" or (rs("tp_apos") < norm and rs("tp_apos") < esp) Then%> <td> <input type="text" name="apos<%=cont%>" style="background:#D2F7DB" size ="3" value ="<%= rs("tp_apos") %>"> </td> <%Else%> <td><input type="text" name="apos<%=cont%>" size ="3" value ="<%= rs("tp_apos") %>"></td> <%End IFsalario = FormatNumber(rs("salario"))IF IsNull(rs("salario")) OR rs("salario") = "0" or rs("salario") = "" or salario < 380.00 Then%> <td bgcolor=#eeeeee> <input name="sal<%=cont%>" type="text" style="background:#D2F7DB" size ="10" value ="<%= salario %>"> </td> <%Else%> <td bgcolor=#eeeeee><input name="sal<%=cont%>" type="text" size ="10" value ="<%= salario %>"></td> <%End IFIF IsNull(rs("n_dep")) OR rs("n_dep") = "" Then%> <td> <input type="text" name="filhs<%=cont%>" style="background:#D2F7DB" size ="2" value ="<%= rs("n_dep") %>"> </td> <%Else%> <td> <input type="text" name="filhs<%=cont%>" size="2" value="<%= rs("n_dep") %>"> </td> <%End IFIF IsNull(rs("dt_conj")) OR (estado(rs("est_civ")) = "Casado" and rs("dt_conj")="") or estado(rs("est_civ")) <> casado Then%> <td bgcolor=#eeeeee> <input name="conj<%=cont%>" type="text" style="background:#D2F7DB" size ="10" value ="<%= rs("dt_conj") %>"> </td> <%Else%> <td bgcolor=#eeeeee><input name="conj<%=cont%>" type="text" size ="10" value ="<%= rs("dt_conj") %>"></td> <%End IFdt_fl1 = Dtatual(rs("dt_nf1")) IF IsNull(rs("dt_nf1")) OR rs("dt_nf1") = "0" or rs("n_dep") < 1 or(rs("n_dep") = 1 and rs("dt_nf1") = "" ) or data_nasc - dt_fl1 =< 15 Then%> <td> <input type="text" name="f1<%=cont%>" style="background:#D2F7DB" size ="10" value ="<%= rs("dt_nf1") %>"> </td> <%Else%> <td><input type="text" name="f1<%=cont%>" size ="10" value ="<%= rs("dt_nf1") %>"></td> <%End IF IF IsNull(rs("dt_nf2")) OR rs("dt_nf2") = "0" or (rs("n_dep") = 2 and rs("dt_nf2") = "" ) Then%> <td bgcolor=#eeeeee> <input name="f2<%=cont%>" type="text" style="background:#D2F7DB" size ="10" value ="<%= rs("dt_nf2") %>"> </td> <%Else%> <td bgcolor=#eeeeee><input name="f2<%=cont%>" type="text" size ="10" value ="<%= rs("dt_nf2") %>"></td> <%End IFIF IsNull(rs("dt_nf3")) OR rs("dt_nf3") = "0" or (rs("n_dep") = 3 and rs("dt_nf3") = "" )Then%> <td> <input type="text" name="f3<%=cont%>" style="background:#D2F7DB" size ="10" value ="<%= rs("dt_nf3") %>"> </td> <%Else%> <td><input type="text" name="f3<%=cont%>" size ="10" value ="<%= rs("dt_nf3") %>"></td> <%End IfIF IsNull(rs("dt_nf4")) OR rs("dt_nf4") = "0" or (rs("n_dep")= 4 and rs("dt_nf4") = "" ) Then%> <td> <input type="text" name="f4<%=cont%>" style="background:#D2F7DB" size ="10" value ="<%= rs("dt_nf4") %>"> </td> <%Else%> <td><input type="text" name="f4<%=cont%>" size ="10" value ="<%= rs("dt_nf4") %>"></td> <%End IfIF IsNull(rs("dt_nf5")) OR rs("dt_nf5") = "0" or (rs("n_dep") = 5 and rs("dt_nf5") = "" ) Then%> <td> <input type="text" style="background:#D2F7DB" name="f5<%=cont%>" size ="10" value ="<%= rs("dt_nf5") %>"> </td> <%Else%> <td><input type="text" name="f5<%=cont%>" size ="10" value ="<%= rs("dt_nf5") %>"></td> <%End If%> <td><span class="style2"> <%=rs("dt_ult_atual")%></span></td> <%totalregistros=totalregistros+contrs.MoveNextLoop%> <input type="hidden" name="hidTotalRegistros" value="<%=totalregistros%>"> </form> <% response.write "</tr>" %> </table> <% Set rs = NothingConn.CloseSet Conn = Nothing %>
Página que faz o update das informações
tipo = Request.Form("tipo")municipio = Request.Form("municipio")set Conn=server.CreateObject("ADODB.Connection")Conn.open="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="& Server.MapPath("/conv/Dados.mdb")sq1 = "Select * from Ativos where tipo = '"&tipo&"' and entidade = '"&municipio&"' "Set RS = Conn.execute (sq1)totalregistros=Request("hidTotalRegistros")'se coloco on resume next dá Script Timeout, se não coloca aparece o erro: Syntax error in UPDATE statement. nas SqlsFor cont=1 to totalregistroscodigo="id"&contvarCodigo=Request(codigo)Sql0="Update Ativos set matricula = "& Request("matrig"&cont)&" where id= "& varCodigo &""Conn.execute(Sql0)Sql="Update Ativos set sexo = '"& Request("sexo"&cont) &"' where id="& varCodigo &""Conn.execute(Sql)Sql1="Update Ativos set est_civ = '"& Request("estciv"&cont) &"' where id="& varCodigo &""Conn.execute(Sql1)Sql2="Update Ativos set dt_nasc = '"& Request("dtnasc"&cont) &"' where id="& varCodigo &""Conn.execute(Sql2)Sql3="Update Ativos set inss_ant = "& Request("inss"&cont) &" where id="& varCodigo &""Conn.execute(Sql3)Sql4="Update Ativos set dt_rp = '"& Request("rp"&cont) &"' where id="& varCodigo &""Conn.execute(Sql4)Sql5="Update Ativos set dt_adm = '"& Request("adm"&cont) &"' where id="& varCodigo &""Conn.execute(Sql5)Sql6="Update Ativos set tp_apos= '"& Request("apos"&cont) &"' where id="& varCodigo &""Conn.execute(Sql6)Sql7="Update Ativos set salario = '"& FormatNumber(Request("sal"&cont)) &"' where id="& varCodigo &""Conn.execute(Sql7)Sql8="Update Ativos set n_dep = "& Request("filhs"&cont) &" where id="& varCodigo &""Conn.execute(Sql8)Sql9="Update Ativos set dt_conj = '"& Request("conj"&cont) &"' where id="& varCodigo &""Conn.execute(Sql9)Sql10="Update Ativos set dt_nf1 = '"& Request("f1"&cont) &"' where id="& varCodigo &""Conn.execute(Sql10)Sql11="Update Ativos set dt_nf2 = '"& Request("f2"&cont) &"' where id="& varCodigo &""Conn.execute(Sql11)Sql12="Update Ativos set dt_nf3 = '"& Request("f3"&cont) &"' where id="& varCodigo &""Conn.execute(Sql12)Sql13="Update Ativos set dt_nf4 = '"& Request("f4"&cont) &"' where id="& varCodigo &""Conn.execute(Sql13)Sql14="Update Ativos set dt_nf5 = '"& Request("f5"&cont) &"' where id="& varCodigo &""Conn.execute(Sql14)NextSet RS = NothingConn.CloseSet Conn = Nothing
Se alguém souber por favor dá uma luz...
Bjs
Carregando comentários...