
























Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Prepare-se para as provas
Estude fácil! Tem muito documento disponível na Docsity
Prepare-se para as provas com trabalhos de outros alunos como você, aqui na Docsity
Encontra documentos específicos para os exames da tua universidade
Prepare-se com as videoaulas e exercícios resolvidos criados a partir da grade da sua Universidade
Responda perguntas de provas passadas e avalie sua preparação.
Ganhe pontos para baixar
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Apostilas de Informática sobre Active Server Pages, Como rodar páginas ASP em um micro com Windows 95/98, Rodando ASP fora do Ambiente WINDOWS, Funcionamento, Convenção e Simbologia.
Tipologia: Notas de estudo
1 / 32
Esta página não é visível na pré-visualização
Não perca as partes importantes!

























' cursor, read only, and telling it that "scratch" is a table name and ' not a SQL command. If I don't specify how to open the rs, I'd get the ' default cursor type which doesn't support .RecordCount! rsCount.Open "scratch", DB_CONNSTRING, adOpenStatic, adLockReadOnly, adCmdTable
' Show RecordCount ' I dress it up and pop it into the middle of a sentence, but you can ' do whatever you want with it. Response.Write "This table currently has <FONT COLOR=""#FF0000"">" Response.Write rsCount.RecordCount ' This is the line that does it! Response.Write " records in it!
" & vbCrLf
' Now I'm going to display the table if they requested it just so you ' have something to look at! This really doesn't pertain to the topic ' of this sample so I'm going to keep the code short but feel free to ' look it over and if you do please notice the pretty HTML it outputs! ' Ugly HTML output is a pet peeve of mine! ;) If LCase(Request.QueryString("showtable")) = "true" Then Dim Field ' Field Looper for display Dim bColor ' Use for showing alternating colors bColor = False
' Spacers and intro Response.Write "
" & vbCrLf & "They are:
" & vbCrLf & "
" & vbCrLf
' Start the table Response.Write "<TABLE BORDER=""1"">" & vbCrLf
' Write Titles Response.Write vbTab & "
' Loop through records outputting data Do While Not rsCount.EOF Response.Write vbTab & "
' Decide what color to output If bColor Then Response.Write "#CCCCFF" ' Light blueish Else Response.Write "#FFFFFF" ' White End If
Response.Write """>" & Field.Value & "" & vbCrLf Next 'Field
Response.Write vbTab & "
' Toggle our colors bColor = Not bColor rsCount.MoveNext Loop
' End the table Response.Write "" & vbCrLf Response.Write "
<A HREF=""db_count.asp"">Hide the table" & vbCrLf Else Response.Write "
<A HREF=""db_count.asp?showtable=true"">Show the table" & vbCrLf End If ' END TABLE DISPLAY - Now back to our regularly scheduled code! '======================================================================
' Close and dispose of recordset object rsCount.Close Set rsCount = Nothing %>
I wrote this sample to answer the question that I'm sure has been on everyone's mind: "How long can an ASP reference site go before putting up a sample hit counter script?" Well whatever the old record was I think we probably shattered it! I've finally broken down and decided to write one. It's pretty simplistic and doesn't really show off the power of ASP, but what do you want... after all it is just a counter!
It stores it's value in a textfile and counts each request. I didn't bother with a session count. If you're interested in that see my article "Counting Active Users!" and just remove the line that decrements the count!
What I did do is take into account some of the things that you might want in a hit counter. First of all you can use this script two different ways. You can cut and paste it into the page you want the count to appear on or you can use it as an include file and just place one line of text in the document where you want the count to appear. The text should look something like this:
One thing to note about using this syntax is that the count file it creates will be wherever the file doing the including is located and this is not necessarily where the script is located! This may be confusing at first, but it allows you to include the same file and run multiple independent counters on different pages with only one set of the code!Another thing to note is that it'll create it's own file to keep track of the count if it doesn't find one. This makes it pretty darn easy to install. The main problem you might run into is if NTFS permissions don't allow the anonymous internet user to write to the counter.txt file. Once you get any NTFS issues straightened out all should be right with the world!
The last thing that bears mentioning is that, as it stands, the script will let you choose either plain text or a set of images. You can toggle this by setting the images querystring parameter to true or false. If you always use one or the other it probably makes sense to hard code the value in, but for illustration and flexability I let you change it on the fly. And for those of you who actually care (and are still reading this) the default is to use text. <% ' Declare our vaiables Dim objFSO, objCountFile ' object vars for FSO and File Dim strCountFileName ' filename of count text file
' We're all done with the hard part ' All that's left is to display the results If bUseImages Then ' Loop through the count integer showing each digit ' You can grab the images one at a time or get the zip ' http://www.asp101.com/samples/download/counter_imgs.zip For I = 1 to Len(iCount) ' Output the IMG tag using the right digit Response.Write "<IMG SRC=""./images/digit_" Response.Write Mid(iCount, I, 1) Response.Write ".gif"" ALT=""" Response.Write Mid(iCount, I, 1) Response.Write """ WIDTH=""20"" HEIGHT=""27"">" Next 'I Else ' No image wanted just show the variable Response.Write iCount End If %>
P/ adionar um cookies
Cookie to add:
Cookie Name:
Cookie Value:
Set Cookie
HTML gerado pelo ASP