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

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> ")

Set objRs = Nothing
Set objDbConn = Nothing

Back to top

Including Files

Below content is from an include file:

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

Back to top

Persits Mail Sender Sample
' change to address of your own SMTP server
' To use BulkRegister 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
     bSuccess = True
End If

End If



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

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

            <td>Host (change as necessary in script):</td>
            <td>From (enter sender's address):<>/td>
            <td><INPUT TYPE="TEXT" NAME="From"></td>
            <td>FromName (optional, enter sender's name):</td>
            <td><INPUT TYPE="TEXT" NAME="FromName"></td>
            <td>To: (enter one recipient's address):</td>
             <td><INPUT TYPE="TEXT" NAME="To"></td>
            <td><INPUT TYPE="TEXT" NAME="Subject"></td>
            <td><TEXTAREA NAME="Body"></TEXTAREA></td>
            <td COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
Back to top

Resize Images Sample
<TITLE>Resize Image</TITLE>

'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">

Back to top

Sign Up Now! Overview

Questions? Call sales at
1 (425) 974-4688
Or try our
Visit our Help Center where you can get simple and quick product support.
bulkregister.com   is an affiliate of   , a leading domain name services company.
Copyright © 1999-2019 BulkRegister. All rights reserved. Terms & Conditions | Privacy Policy | Abuse Policy