<%
Dim Total,garotos,garotas
Set bd = Server.CreateObject("ADODB.Connection")
bd.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/tudo.mdb")
Set tabrs = Server.CreateObject("ADODB.recordset")
tabrs.open "tblCad",bd,1,3
total = tabrs.recordcount
tabrs.movefirst
while not(tabrs.Eof)
if tabrs("MascFem")="1" then
garotos=garotos+1
end if
if tabrs("MascFem")="0" then
garotas=garotas+1
end if
wend
tabrs.close
bd.close
%>
E neste:
<%
Dim Connection, SQLquery, RS, Total, Garotos, Garotas
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/cadastros.mdb")
SQLquery = "SELECT count(*) AS total FROM tblCad WHERE Adicionado=1"
Set RS = Connection.Execute(SQLquery)
Total = RS("total").Value
Garotos = RS("MasFem=1").Value
Garotas = RS("MasFem=0").Value
%>
Pergunta
[ GuTo ]
Tenho 2 códigos, preste atenção!
O que tem de errado neste código?
<% Dim Total,garotos,garotas Set bd = Server.CreateObject("ADODB.Connection") bd.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/tudo.mdb") Set tabrs = Server.CreateObject("ADODB.recordset") tabrs.open "tblCad",bd,1,3 total = tabrs.recordcount tabrs.movefirst while not(tabrs.Eof) if tabrs("MascFem")="1" then garotos=garotos+1 end if if tabrs("MascFem")="0" then garotas=garotas+1 end if wend tabrs.close bd.close %>E neste:<% Dim Connection, SQLquery, RS, Total, Garotos, Garotas Set Connection = Server.CreateObject("ADODB.Connection") Connection.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/cadastros.mdb") SQLquery = "SELECT count(*) AS total FROM tblCad WHERE Adicionado=1" Set RS = Connection.Execute(SQLquery) Total = RS("total").Value Garotos = RS("MasFem=1").Value Garotas = RS("MasFem=0").Value %>Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.