revisando viejos sites me aparecio este codigo:
Código:
' On Error Resume Next
bdporra="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("./fpdb/porra.mdb")&";"
'****************abre
Set con1votat = Server.CreateObject("ADODB.Connection")
Set rsG1votat = Server.CreateObject("ADODB.RecordSet")
con1votat.open bdporra
sql1votat = "SELECT Count(*) AS totalregistros FROM Emailsgo"
rsG1votat.Open sql1votat, con1votat
hanvotat=rsG1votat("totalregistros")
If Not IsNumeric(hanvotat) Then hanvotat=0 end if
rsG1votat.Close
Set rsG1votat = Nothing
con1votat.close
Set con1votat = Nothing
'**************** cierra
'****************abre
Set con1nohan = Server.CreateObject("ADODB.Connection")
Set rsG1nohan = Server.CreateObject("ADODB.RecordSet")
'On Error Resume Next
con1nohan.open bdporra
sql1nohan = "SELECT Count(*) AS ntotalregistros FROM EmailTem"
rsG1nohan.Open sql1nohan, con1nohan
nohanvotat=rsG1nohan("ntotalregistros")
rsG1nohan.Close
Set rsG1nohan = Nothing
con1nohan.close
Set con1nohan = Nothing
'****************cierra
'****************abre
Set conporra = Server.CreateObject("ADODB.Connection")
Set rsGporra = Server.CreateObject("ADODB.RecordSet")
conporra.open bdporra
sqlporra = "SELECT SUM(T1) AS CIU, SUM(T2) AS PSC, SUM(T3) AS PP, SUM(T4) AS ERC, SUM(T5) AS ICV, SUM(T6) AS GIR, SUM(T7) AS GLO FROM Emailsgo"
rsGporra.Open sqlporra, conporra
t1 =rsGporra("CIU")
If Not IsNumeric(t1) Then t1=0.1 end if
t2 = rsGporra("PSC")
If Not IsNumeric(t2) Then t2=0.1 end if
t3 = rsGporra("PP")
If Not IsNumeric(t3) Then t3=0.1 end if
t4 = rsGporra("ERC")
If Not IsNumeric(t4) Then t4=0.1 end if
t5 = rsGporra("ICV")
If Not IsNumeric(t5) Then t5=0.1 end if
t6 = rsGporra("GIR")
If Not IsNumeric(t6) Then t6=0.1 end if
t7 = rsGporra("GLO")
If Not IsNumeric(t7) Then t7=0.1 end if
sumatotal=(+t1+t2+t3+t4+t5+t6)
If Not IsNumeric(sumatotal) Then sumatotal=0 end if
rsGporra.Close
Set rsGporra = Nothing
conporra.close
Set conporra = Nothing
'****************cierra
y ahora, como creo deberia estar para maximizar la conexion y ahorrar recursos:
' On Error Resume Next
bdporra="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("./fpdb/porra.mdb")&";"
Set con1votat = Server.CreateObject("ADODB.Connection")
Set rsG1votat= Server.CreateObject("ADODB.RecordSet")
con1votat.open bdporra
'****************sigue
sql1votat = "SELECT Count(*) AS totalregistros FROM Emailsgo"
rsG1votat=con1votat.Execute(sql1votat)
hanvotat=rsG1votat("totalregistros")
If Not IsNumeric(hanvotat) Then hanvotat=0 end if
'****************sigue
sql1votat = "SELECT Count(*) AS ntotalregistros FROM EmailTem"
rsG1votat=con1votat.Execute(sql1votat)
nohanvotat=rsG1votat("ntotalregistros")
'****************sigue
sql1votat = "SELECT SUM(T1) AS CIU, SUM(T2) AS PSC, SUM(T3) AS PP, SUM(T4) AS ERC, SUM(T5) AS ICV, SUM(T6) AS GIR, SUM(T7) AS GLO FROM Emailsgo"
rsG1votat=con1votat.Execute(sql1votat)
t1 =rsG1votat("CIU")
If Not IsNumeric(t1) Then t1=0.1 end if
t2 = rsG1votat("PSC")
If Not IsNumeric(t2) Then t2=0.1 end if
t3 = rsG1votat("PP")
If Not IsNumeric(t3) Then t3=0.1 end if
t4 = rsG1votat("ERC")
If Not IsNumeric(t4) Then t4=0.1 end if
t5 = rsG1votat("ICV")
If Not IsNumeric(t5) Then t5=0.1 end if
t6 = rsG1votat("GIR")
If Not IsNumeric(t6) Then t6=0.1 end if
t7 = rsG1votat("GLO")
If Not IsNumeric(t7) Then t7=0.1 end if
sumatotal=(+t1+t2+t3+t4+t5+t6)
If Not IsNumeric(sumatotal) Then sumatotal=0 end if
Set rsG1votat = Nothing
con1votat.close
Set con1votat = Nothing
'****************cierra
aguna opinion o critica?