aspx thread: Re: Counting records Into a Standard variable.
Thanks for your answers, it oriented me a lot!
Finally the little code I get to count records is the following (Using
Vb.net and an access database (mdb):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Little Example counting records.</title>
</head>
<body>
<%@ Page Language="VB" Debug="True"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
sub Page_Load(obj as Object, e as EventArgs)
dim Conn as new OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=" & Server.MapPath("calendario.mdb") & ";")
dim objCmd as new OleDbCommand ("select count (*) as Total from
tbCalendar", Conn)
dim cont as integer
cont=0
response.write ("<h1>Resultados de la operación: </h1>")
Try
objCmd.Connection.Open()
cont = objCmd.ExecuteScalar
Finally
objCmd.Connection.Close()
response.write ("<center>El resultado es: ")
response.write (cont)
response.write ("</center>")
End Try
end sub
</script>
</body>
</html>
From Spain,
Salvador Gallego.