ASP Classic 3.0 and Microsoft Access FAQs
|
How can I protect my ASP Classic 3.0 source code from being
stolen?
|
| |
|
DWebPro includes the DWebPro Encoder Software, which is a PHP/ASP Classic 3.0 encoder that provides an entry
level solution for source code protection. |
| |
|
How can I send email using ASP Classic 3.0?
|
| |
|
The ASP Classic 3.0 support provided by DWebPro includes some
features not available in Microsoft ASP, one of these feature is the Mail object.
The Server.NewMail() method returns
an instance of Mail object (as CDONTS.NewMail does). This object can be used to send emails through the SMTP server
specified in the ASP Classic 3.0 configuration file (refer to the ASP Classic 3.0 Support topic).
The differences between Server.NewMail() and CDONTS.NewMail are:
-
Value() behaves differently (see
below)
-
AttachURL() behaves differently
(see below)
-
Send() returns a value that specify
the success of the email shipment
-
Body can be only a string
-
SetLocaleIDs are ignored
Below are some examples of how to use Server.NewMail:
-
Send a plain text email without attachments.
Dim Mail
Set Mail = Server.NewMail
Mail.From = "from@example.com"
Mail.To = "to@example.com"
Mail.Subject = "This is the subject of the sample email"
Mail.Body = "This is the body of the sample email"
Mail.Send
Set Mail = nothing
- Send an HTML email without attachments.
Dim Mail
Set Mail = Server.NewMail
Mail.From = "from@example.com"
Mail.To = "to@example.com"
Mail.Subject = "Test mail"
Mail.Body = "<html><body><strong>Hello World!</strong></body></html>"
Mail.MailFormat = 0 ' MIME
Mail.BodyFormat = 0 ' HTML
Mail.Send
Set Mail = nothing
- Send a plain text email with attachments.
Dim Mail
Set Mail = Server.NewMail
Mail.From = "from@example.com"
Mail.To = "to@example.com"
Mail.Subject = "This is the subject of the sample email"
Mail.Body = "This is the body of the sample email"
Mail.AttachFile(Server.MapPath("images/dwebpro_box.gif"))
Mail.MailFormat = 0 ' MIME
Mail.Send
Set Mail = nothing
- Send an HTML email with attachments.
Dim Mail
Set Mail = Server.NewMail
Mail.From = "from@example.com"
Mail.To = "to@example.com"
Mail.Subject = "Test mail"
Mail.Body = "<html><body><strong>Hello World!</strong></body></html>
Mail.AttachFile(Server.MapPath("images/dwebpro_box.gif"))
Mail.MailFormat = 0 ' MIME
Mail.BodyFormat = 0 ' HTML
Mail.Send
Set Mail = nothing
- Send an HTML email with embedded attachments.
Dim Mail
Set Mail = Server.NewMail
Mail.From = "from@example.com"
Mail.To = "to@example.com"
Mail.Subject = "Test mail"
Mail.Body = "<html><body><img src='cid:embeddedpic'/>"
Mail.Body = Mail.Body & "<strong>Hello World!</strong></body></html>"
Mail.AttachURL Server.MapPath("images/dwebpro_box.gif"), "EmbeddedPic"
Mail.MailFormat = 0 ' MIME
Mail.BodyFormat = 0 ' HTML
Mail.Send
Set Mail = nothing
- Usage of the
Value method
(different than CDONTS.NewMail).
Dim Mail
Set Mail = Server.NewMail
Mail.From = "from@example.com"
Mail.To = "to@example.com"
Mail.Subject = "This is the subject of the sample email"
Mail.Body = "This is the body of the sample email"
Mail.Value("Organization", "Your Company")
Mail.Send
Set Mail = nothing
- Usage of
Send() return value.
Dim Mail
Dim RetVal
Set Mail = Server.NewMail
Mail.From = "from@example.com"
Mail.To = "to@example.com"
Mail.Subject = "This is the subject of the sample email"
Mail.Body = "This is the body of the sample email"
RetVal = Mail.Send
if (RetVal = 0) then
Response.Write("Mail sent successfully!")
elseif (RetVal = 1) then
Response.Write("Socket error (check SMTP server connection)!")
elseif (RetVal = 2) then
Response.Write("Protocol error (check mail properties)!")
else
Response.Write("Unknown error !")
end if
Set Mail = nothing
Here are the Mail object properties and
methods:
Write-only properties:
-
From: string;
-
To: string;
-
Bcc: string;
-
CC: string;
-
Importance: integer;
-
0 = Low
-
1 = Normal (default)
-
2 = High
-
Subject: string;
-
Body: string;
-
ContentLocation: string;
-
ContentBase: string;
-
BodyFormat: integer;
-
0 = HTML
-
1 = Text (default)
-
MailFormat: integer;
-
0 = MIME
-
1 = Text (default)
Read-only property:
Methods:
-
procedure Value(Item, Value: string);
-
procedure AttachFile(Source: string; optional FileName:
string; optional EncodingMethod: integer);
-
procedure AttachURL(source: string; optional cid:
string; optional encodingmethod: integer);
-
function Send(From: string; optional To: string; optional
Subject: string; optional Body: string; optional Importance: integer):
integer;
|
| |
|
Which connection string should I have to use for connecting
to a Microsoft Access database?
|
| |
|
The connection string to use depends on the access mode you
need. If you need to read and write database content, you have to
configure DWebPro to copy the database file on the user's file system
and create a connection string that points to that path.
For instance, if you want to establish a read/write connection
to the Northwind.mdb database, perform the following
steps:
-
Copy the database to a dedicated folder in the deploy directory (for example, deploy\database).
-
Edit the MsAccess section of the http.ini file as follows:
[MsAccess]
DestinationDir=##DWEBPRO_TEMP##\database
DataDir=##DWEBPRO_PATH##\database
CopyDataToHardDisk=1
The above configuration tells DWebPro to copy the data (CopyDataToHardDisk=1) from the ##DWEBPRO_PATH##\database folder into the ##DWEBPRO_TEMP##\database folder.
-
Edit your connection string as follows (VBScript sample
code):
<%
DIM ConnectionString
ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Request.ServerVariables("DWEBPRO_TEMP") & _
"\database\Northwind.mdb;" & _
"UID=admin;PWD=;"
%>
or as follows (VBScript sample code):
<%
DIM ConnectionString
ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Request.ServerVariables("DWEBPRO_MSACCESS_DATADIR") & _
"Northwind.mdb;" & _
"UID=admin;PWD=;"
%>
Refer to the DWebPro Internal Constants topic and to the How to Read DWebPro Internal Constants from Code how-to for additional information on paths.
If you only need to read the database content, you can leave
the database file on the CD/DVD and add two additional parameters
to the connection string: ReadOnly=1 and Exclusive=1.
For instance, if you want to establish a read-only connection
to the Northwind.mdb database, perform the following
steps:
-
Copy the database to a dedicated folder in the deploy directory (for example, deploy\database).
-
Edit your connection string as follows (VBScript sample
code):
<%
DIM ConnectionString
ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Request.ServerVariables("DWEBPRO_PATH") & _
"\database\Northwind.mdb;" & _
"UID=admin;PWD=;ReadOnly=1;Exclusive=1;"
%>
|
| |
|
Can I make the ASP Classic 3.0 engine execute .HTM and .HTML web pages ?
|
| |
|
Of course you can! Open the http.ini file and search for the ASP Classic 3.0 reference in the ISAPI section. You will find something like the following:
[ISAPI0] Path=##DWEBPRO_PATH##\engine\aspclassic\aspisapi.dll Extensions=.asp|.asa
The above configurations tells DWebPro to make the ASP Classic 3.0 engine execute the files specified in the Extensions field (.asp|.asa).
To make it execute the .htm and .html files you have only to add them th the Extensions field.
[ISAPI0] Path=##DWEBPRO_PATH##\engine\aspclassic\aspisapi.dll Extensions=.asp|.asa|.htm|.html
Refer to the ISAPI and ASP Classic 3.0 Support topics for more information about ASP Classic 3.0 support and configuration. |
| |
|
How can I know when the web application is running under DWebPro (i.e. for conditional configuration)?
|
| |
|
DWebPro sets the SERVER_SOFTWARE server variable with the "DWebPro" strings. You can use a code like the following to identify when you web application is running under DWebPro or another web server.
<%
If (Request.ServerVariables("SERVER_SOFTWARE") = "DWebPro") then
Response.Write("This application is running under DWebPro!")
Else
Response.Write("This application is <b>not running</b> under DWebPro!")
End If
%>
This feature is useful if you want to use the same code base for your online and CD based web application. For instance you can use a code like the following for your configuration file:
<%
If (Request.ServerVariables("SERVER_SOFTWARE") = "DWebPro") then
// Insert here the DWebPro configuration
Else
// Insert here the IIS configuration
End If
%>
|