Web Site Creator Web Hosting Help
   ASP Sample Files


ASP code samples, such as connecting to an Access database, are now available. Log into your Web Hosting control panel and go to the Help section to create Sample Files in your Web Hosting account. A folder named "samplefiles" will be created in the root directory containing the samples, with the necessary account information already filled in. Any time a new code sample is released it will be added to this folder in your account.

For your convenience, some of the code samples are included below. Always be sure to check your "samplefiles" folder for the most recent versions of these samples. Highlighted text should be replaced according to details of your account.

Sample Files

Database Sample
Including Files
Persits Mail Sender Sample
Resize Images Sample

Database Sample
<%

Dim sDBPath : sDBPath = "\myaccount\db\mydbsample.mdb"

Set objDbConn = Server.CreateObject("ADODB.Connection")
objDbConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath(sDBPath)

Response.write "<b>Making select statement:</b><br>"

Set objRs = objDbConn.Execute( "SELECT * FROM Employees" )

' Print out all the records
While Not objRs.EOF
Response.Write("&nbsp;&nbsp;Record returned:<b> " & objRs( 0 ) & "&nbsp;" & objRs( 1 ) & "&nbsp;" & objRs( 2 ) & "</b><br>" )
' Move to the next record
objRs.MoveNext
Wend

Response.write "<br><b>Making insert statement:</b><br>"
objDbConn.Execute( "insert into Employees (FirstName, LastName, StartDate) values ('Daniel','Svensson', '"& Now() &"')" )
Response.Write("&nbsp;&nbsp;Inserted:<b> Daniel Svensson </b>" & Now() )

Response.write "<br><b>Making update statement:</b><br>"
objDbConn.Execute( "update Employees set FirstName = 'Pierre' where LastName = 'Svensson' And FirstName = 'Daniel'" )
Response.Write("&nbsp;&nbsp;Updated:<b> Daniel Svensson to Pierre Svensson </b> ")

Response.write "<br><b>Making delete statement:</b><br>"
objDbConn.Execute( "delete * from Employees where LastName = 'Albertsson' And FirstName = 'Dolly'" )
Response.Write("&nbsp;&nbsp;Deleted:<b>Dolly Albertsson </b> ")

objDbConn.Close
Set objRs = Nothing
Set objDbConn = Nothing

%>
Back to top


Including Files
<html>
<body>

Below content is from an include file:
<br>

<!--#INCLUDE virtual="/myaccount/pathTo/IncludeFile.asp"-->

</body>
</html>
Back to top


Persits Mail Sender Sample
<%
' change to address of your own SMTP server
' To use eNom smtp you must autenticate with your username and password

strHost = "mysmtpserver"

'Uncomment and set username and password here
'strUser = "user@somedomain.com"
'strPassword = "password"

If Request("Send") <> "" Then
Set Mail = Server.CreateObject("Persits.MailSender")
' enter valid SMTP host
Mail.Host = strHost

'Uncomment to use smtp authenctication
'Mail.Username = strUser
'Mail.Password = strPassword

Mail.From = Request("From") ' From address
Mail.FromName = Request("FromName") ' optional
Mail.AddAddress Request("To")

' message subject
Mail.Subject = Request("Subject")
' message body
Mail.Body = Request("Body")
strErr = ""
bSuccess = False
On Error Resume Next ' catch errors
Mail.Send ' send message
If Err <> 0 Then ' error occurred
     strErr = Err.Description
else
     bSuccess = True
End If

End If

%>

<HTML>
<BODY BGCOLOR="#FFFFFF">

<% If strErr <> "" Then %>
      <h3>Error occurred: <% = strErr %>
<% End If %>

<% If bSuccess Then %>
      Success! Message sent to <% = Request("To") %>.
<% End If %>


<FORM METHOD="POST" ACTION=""> <TABLE CELLSPACING=0 CELLPADDING=2 BGCOLOR="#E0E0E0">
      <tr>
            <td>Host (change as necessary in script):</td>
            <td><B>mysmtpserver</B></td>
      </tr>
      <tr>
            <td>From (enter sender's address):<>/td>
            <td><INPUT TYPE="TEXT" NAME="From"></td>
      </tr>
      <tr>
            <td>FromName (optional, enter sender's name):</td>
            <td><INPUT TYPE="TEXT" NAME="FromName"></td>
      </tr>
      <tr>
            <td>To: (enter one recipient's address):</td>
             <td><INPUT TYPE="TEXT" NAME="To"></td>
      </tr>
      <tr>
            <td>Subject:</td>
            <td><INPUT TYPE="TEXT" NAME="Subject"></td>
      </tr>
      <tr>
            <td>Body:</td>
            <td><TEXTAREA NAME="Body"></TEXTAREA></td>
      </tr>
      <tr>
            <td COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
           </td>
      </tr>
</TABLE>
</FORM>
</BODY>
</HTML>
Back to top


Resize Images Sample
<HTML>
<HEAD>
<TITLE>Resize Image</TITLE>
</HEAD>
<BODY>

<%
'my userid
Dim myuserid : myuserid = "myloginid"

' Create instance of AspJpeg
Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Compute path to source image
Path = Server.MapPath( "/" & myuserid & "/PathTo/picture.jpg")

' Open source image
Jpeg.Open Path

' Decrease image size by 50%
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / 2

' create thumbnail and save it to disk - to a writeable folder

Jpeg.Save Server.MapPath("/" & myuserid & "/samplefiles/writefolder/apple_small.jpg")

%>

Original Image:<BR>
<IMG SRC="apple.jpg"><p>

Thumbnail (50%):<BR>
<IMG SRC="writefolder/apple_small.jpg">

</BODY>
</HTML>
Back to top



Sign Up Now! Overview

Questions? Call sales at
1 (425) 274-4500
Or try our
Visit our Help Center where you can get simple and quick product support.
   is an affiliate of   , a leading domain name services company.
Copyright © 1998-2018 Enom LLC. All rights reserved. Terms & Conditions | Privacy Policy | Abuse Policy