Thursday, June 22, 2006

Tuesday, June 13, 2006

Display Report from Access using ASP

Here is a post I made on webdeveloper.com asking for some help with ASP, and some guy named Russell posted an amazing instant working code:

Hey there, I am really new to ASP and SQL
My boss gave me the task to do the following:
We have a huge database with a ton of records that specify:
Location, Specialty, Number, and other things. He wants me to create a report that displays

Location1 SpecialtyA Average Number for this specialty
----------SpecialtyB Average Number for this specialty
----------SpecialtyC Average Number for this specialty
Location2 SpecialtyA Average Number for this specialty
----------SpecialtyB Average Number for this specialty
----------SpecialtyC Average Number for this specialty
and so on...

So far I created a page in dreamweaver filled with a huge table with a ton of cells. After connecting the database, what do I type to have it spit out the average number? Something like Response.Write ? Thanks!
Edit/Delete Message


Here is his amazing response code:

<%
main

Sub main()
Dim ar

ar = getData()

If isArray(ar) Then
showReport ar
Else
Response.Write "No Data"
End If
End Sub

Sub showReport(ar)
Dim i

With Response
.Write "<table>" & vbCrLf
.Write "<tr>" & vbCrLf
.Write "<td>Location</td>" & vbCrLf
.Write "<td>Specialty</td>" & vbCrLf
.Write "<td>Avg</td>" & vbCrLf
.Write "</tr>" & vbCrLf

For i = 0 To Ubound(ar, 2)
.Write "<tr>" & vbCrLf
.Write "<td>" & ar(0, i) & "</td>" '' location
.Write "<td>" & ar(1, i) & "</td>" '' specialty
.Write "<td>" & ar(2, i) & "</td>" '' avg
.Write "</tr>" & vbCrLf
Next
.Write "<table>" & vbCrLf
End With
End Sub

Function getData()
Dim cmd
Dim sql
Dim rs

sql = "SELECT location, specialty, AVG(number_for_this_specialty) " &_
"FROM myTable " &_
"GROUP BY location, specialty " &_
"ORDER BY location, specialty"

Set cmd = Server.CreateObject("ADODB.Command")
Set rs = Server.CreateObject("ADODB.Recordset")

With cmd
.ActiveConnection = YOUR_CONNECTION_STRING_HERE
.CommandType = 1 '' adCmdText
.CommandText = sql

rs.Open .Execute
End With

If Not rs.EOF Then
getData = rs.GetRows
rs.Close
End If

Set rs = Nothing
Set cmd = Nothing
End Function
%>

Tuesday, June 06, 2006

Using checkboxes to update multiple database entries

Another page about Using checkboxes to update multiple database entries

Create an animated Avatar

This teaches you how to make an animated gif from your favorite movie clip:
Create an animated Avatar

Simple Unsecure Password Protection

This is a super simple Javascript code for making a popup that asks for only a password to be entered. If it is correct, it will forward you to the private page, if it is incorrect it will forward you to the error page. Any smart person could do a viewsource to see the password, but this is for those pages on a company intranet where the employees barely know how to use a browser. This should not be used for a public website on the internet or your ass will get hacked!

<SCRIPT LANGUAGE="javascript">
var getin = prompt("What is the password?","")
if (getin=="superpassword")
{
location.href="secretpage.html"
}
else
{
if (getin=="null")
{location.href="errorpage.html"}
else
if (getin!="superpassword")
{location.href="errorpage.html"}
</SCRIPT>

Using SQL Set Notation to do Batch Deletes

I am trying to accomplish this, and I have found a link from the 4GuysFromRolla website that I think will help me get it working:
Using SQL Set Notation to do Batch Deletes

Simple Delete From Database

Here is some useful code that I used to help make a single record delete function using ASP for an Access .mdb database:
Simple Delete From Database

Godaddy Forms

Godaddy hosting has two different options: Windows or Linux. With Windows, you are using ASP, and with Linux you are using either PHP or CGI.

In order to make a form in a webpage send you an email with the filled out information, you must:
  1. Have your email set in the 'Form Mail' control panel of your hosted account
  2. Have the code in the webpage "<FORM ACTION="####" METHOD="POST" >
    " where #### will be either the path to the gdform.asp file (for windows) or the path to the gdform.cgi or gdform.php (for linux, both work the same)

Also, it is important to note that after changing your email in the 'Form Mail' control, it takes Godaddy approximately one hour for the update to take effect. So don't get worried if the forms are not sending. Wait a little while.