M
Manoj
Good Afternoon,
I have a a bit of a problem understanding the root of this problem (apart
fromthe fact that I'm very new to this).
I'm trying to learn ASP at the very basic level to start. I'm doing this
from the IIS server documentation. There are a few ASP tutorials and I'm
trying to follow them through.
I'm on the introductory tutorial that teaches how to put information into an
Access database that resides in the webserver folder (in my case,
"C:\inetpub\wwwroot\LearningASP".
The name of the database file is Guestbook.mdb.
The only difference is that I had already created a subweb named
"LearningASP" and the tutorial asks to create a subweb called "Tutorial".
This is the code from the actual Tutorial File which I n:
<%@ Language=VBScript %>
<html>
<head>
<title>Guest Book Using Connection Object Only</title>
</head>
<body>
<font face="arial">
<h2>Guest Book Using Connection Object Only</h2>
<%
If Not Request.QueryString("Message") = "True" Then
'No information has been input yet, so provide the form.
%>
<p>
<FORM NAME="GuestBook1" METHOD="GET" ACTION="guestbook1.asp">
<table>
<tr>
<td><font face="arial">From:</td><td><INPUT TYPE="TEXT" NAME="From"></td>
</tr><tr>
<td><font face="arial">E-mail Address:</td><td><INPUT TYPE="TEXT"
NAME="EmailAdd"></td>
</tr><tr>
<td><font face="arial">CC:</td><td><INPUT TYPE="TEXT" NAME="CC"><td>
</tr><tr>
<td><font face="arial">Subject:</td><td><INPUT TYPE="TEXT"
NAME="Subject"></td>
</tr>
</table>
Message: <br><TEXTAREA NAME="Memo" ROWS=6 COLS=70></TEXTAREA>
</p>
<p>
<INPUT TYPE="HIDDEN" NAME="Message" VALUE="TRUE">
<INPUT TYPE="SUBMIT" VALUE="Submit Information">
</FORM>
</p>
<%
Else
'The HIDDEN button above sets the Message variable to True.
'We know now that the form data has been entered.
'Get the data from the form. We will be inserting it into the database.
'Access doesn't like some characters, such as single-quotes, so encode the
' data using the HTMLEncode method of the ASP Server object.
dim strTB1, strTB2, strTB3, strTB4, strMB1, strCommand
strTB1 = Server.HTMLEncode(Request.QueryString("From"))
strTB2 = Server.HTMLEncode(Request.QueryString("EmailAdd"))
strTB3 = Server.HTMLEncode(Request.QueryString("CC"))
strTB4 = Server.HTMLEncode(Request.QueryString("Subject"))
strMB1 = Server.HTMLEncode(Request.QueryString("Memo"))
'This is a connection string. ADO uses it to connect to a database
through the Access driver.
'It needs the provider name of the Access driver and the name of the
Access database.
'Connection strings are slightly different, depending on the provided
being used,
' but they all use semicolons to separate variables.
'If this line causes and error, search in your registry for
'Microsoft.JET to see if 4.0 is your version.
strProvider = "Provider=Microsoft.JET.OLEDB.4.0;Data
Source=C:\InetPub\Wwwroot\LearningASP\guestbook.mdb;"
'This creates an instance of an ADO Connection object.
'There are 4 other ADO objects available to you, each with different
methods and
'properties that allow you to do almost anything with database data.
Set objConn = server.createobject("ADODB.Connection")
'The Open method of the Connection object uses the connection string to
' create a connection to the database.
objConn.Open strProvider
'Define the query.
'There are many types of queries, allowing you to add, remove, or get data.
'This query will add your data into the database, using the INSERT INTO
key words.
'Here, Guestbook is the name of the table.
'You need single-quotes around strings here.
strCommand = "INSERT INTO Guestbook (FTB1,FTB2,FTB3,FTB4,FMB1) VALUES ('"
strCommand = strCommand & strTB1 & "','" & strTB2 & "','" & strTB3 & "','"
& strTB4 & "','" & strMB1
strCommand = StrCommand & "')"
'Execute the query to add the data into the database.
objConn.Execute strCommand
Response.Write("Thank you! Your data has been added.")
End if
%>
</font>
</body>
</html>
I copied and pasted it into a blank document after running into problems
when I manually entered the code for the first file, "Guestbook1.asp". Here
is the code from "Guestbook1.asp":
<%@ Language=VBScript %>
<html>
<head>
<title>Guest Book Using Connection Object Only</title>
</head>
<body>
<font face="arial">
<h2>Guest Book Using Connection Object Only</h2>
<%
If Not Request.QueryString("Message") = "True" Then
'No information has been input yet, so provide the form.
%>
<p>
<FORM NAME="GuestBook1" METHOD="GET" ACTION="guestbook1.asp">
<table>
<tr>
<td><font face="arial">From:</td><td><INPUT TYPE="TEXT"
NAME="From"></td>
</tr><tr>
<td><font face="arial">E-mail Address:</td><td><INPUT
TYPE="TEXT" NAME="EmailAdd"></td>
</tr><tr>
<td><font face="arial">CC:</td><td><INPUT TYPE="TEXT"
NAME="CC"><td>
</tr><tr>
<td><font face="arial">Subject:</td><td><INPUT TYPE="TEXT"
NAME="Subject"></td>
</tr>
</table>
Message: <br><TEXTAREA NAME="Memo" ROWS=6 COLS=70></TEXTAREA>
</p>
<p>
<INPUT TYPE="HIDDEN" NAME="Message" VALUE="TRUE">
<INPUT TYPE="SUBMIT" VALUE="Submit Information">
</FORM>
</p>
<%
Else
'The HIDDEN button above sets the Message variable to True.
'We know now that the form data has been entered.
'Get the data from the form. We will be inserting it into
the database.
'Access doesn't like some characters, such as
single-quotes, so encode the
' data using the HTMLEncode method of the ASP Server
object.
dim strTB1, strTB2, strTB3, strTB4, strMB1, strCommand
strTB1 = Server.HTMLEncode(Request.QueryString("From"))
strTB2 = Server.HTMLEncode(Request.QueryString("EmailAdd"))
strTB3 = Server.HTMLEncode(Request.QueryString("CC"))
strTB4 = Server.HTMLEncode(Request.QueryString("Subject"))
strMB1 = Server.HTMLEncode(Request.QueryString("Memo"))
'This is a connection string. ADO uses it to connect to a
database through the Access driver.
'It needs the provider name of the Access driver and the
name of the Access database.
'Connection strings are slightly different, depending on
the provided being used,
' but they all use semicolons to separate variables.
'If this line causes and error, search in your registry for
'Microsoft.JET to see if 4.0 is your version.
strProvider = "Provider=Microsoft.JET.OLEDB.4.0;Data
Source=C:\InetPub\Wwwroot\LearningASP\guestbook.mdb;"
'This creates an instance of an ADO Connection object.
'There are 4 other ADO objects available to you, each with
different methods and
'properties that allow you to do almost anything with
database data.
Set objConn = server.createobject("ADODB.Connection")
'The Open method of the Connection object uses the
connection string to
' create a connection to the database.
objConn.Open strProvider
'Define the query.
'There are many types of queries, allowing you to add,
remove, or get data.
'This query will add your data into the database, using the
INSERT INTO key words.
'Here, Guestbook is the name of the table.
'You need single-quotes around strings here.
strCommand = "INSERT INTO Guestbook
(FTB1,FTB2,FTB3,FTB4,FMB1) VALUES ('"
strCommand = strCommand & strTB1 & "','" & strTB2 & "','" &
strTB3 & "','" & strTB4 & "','" & strMB1
strCommand = StrCommand & "')"
'Execute the query to add the data into the database.
objConn.Execute strCommand
Response.Write("Thank you! Your data has been added.")
End if
%>
</font>
</body>
</html>
Like I said I first manually typed up Guestbook1.asp and for some reason,
the page would appear in IE, but after entering the fields, it wouldn't
upload the data to the Access file.
Opened another blank file and just copied and pasted the tutorial code into
it and named it Guestboo11.asp and changed the references to match the file
name as well as the location of the database and this one worled perfectly
fine!
I'm trying to understand where I went wrong. I tried to do a side-by-side
comparison without any luck.
Any advise or information for a poor sod trying to learning this stuff?
Thanks!
Manoj
I have a a bit of a problem understanding the root of this problem (apart
fromthe fact that I'm very new to this).
I'm trying to learn ASP at the very basic level to start. I'm doing this
from the IIS server documentation. There are a few ASP tutorials and I'm
trying to follow them through.
I'm on the introductory tutorial that teaches how to put information into an
Access database that resides in the webserver folder (in my case,
"C:\inetpub\wwwroot\LearningASP".
The name of the database file is Guestbook.mdb.
The only difference is that I had already created a subweb named
"LearningASP" and the tutorial asks to create a subweb called "Tutorial".
This is the code from the actual Tutorial File which I n:
<%@ Language=VBScript %>
<html>
<head>
<title>Guest Book Using Connection Object Only</title>
</head>
<body>
<font face="arial">
<h2>Guest Book Using Connection Object Only</h2>
<%
If Not Request.QueryString("Message") = "True" Then
'No information has been input yet, so provide the form.
%>
<p>
<FORM NAME="GuestBook1" METHOD="GET" ACTION="guestbook1.asp">
<table>
<tr>
<td><font face="arial">From:</td><td><INPUT TYPE="TEXT" NAME="From"></td>
</tr><tr>
<td><font face="arial">E-mail Address:</td><td><INPUT TYPE="TEXT"
NAME="EmailAdd"></td>
</tr><tr>
<td><font face="arial">CC:</td><td><INPUT TYPE="TEXT" NAME="CC"><td>
</tr><tr>
<td><font face="arial">Subject:</td><td><INPUT TYPE="TEXT"
NAME="Subject"></td>
</tr>
</table>
Message: <br><TEXTAREA NAME="Memo" ROWS=6 COLS=70></TEXTAREA>
</p>
<p>
<INPUT TYPE="HIDDEN" NAME="Message" VALUE="TRUE">
<INPUT TYPE="SUBMIT" VALUE="Submit Information">
</FORM>
</p>
<%
Else
'The HIDDEN button above sets the Message variable to True.
'We know now that the form data has been entered.
'Get the data from the form. We will be inserting it into the database.
'Access doesn't like some characters, such as single-quotes, so encode the
' data using the HTMLEncode method of the ASP Server object.
dim strTB1, strTB2, strTB3, strTB4, strMB1, strCommand
strTB1 = Server.HTMLEncode(Request.QueryString("From"))
strTB2 = Server.HTMLEncode(Request.QueryString("EmailAdd"))
strTB3 = Server.HTMLEncode(Request.QueryString("CC"))
strTB4 = Server.HTMLEncode(Request.QueryString("Subject"))
strMB1 = Server.HTMLEncode(Request.QueryString("Memo"))
'This is a connection string. ADO uses it to connect to a database
through the Access driver.
'It needs the provider name of the Access driver and the name of the
Access database.
'Connection strings are slightly different, depending on the provided
being used,
' but they all use semicolons to separate variables.
'If this line causes and error, search in your registry for
'Microsoft.JET to see if 4.0 is your version.
strProvider = "Provider=Microsoft.JET.OLEDB.4.0;Data
Source=C:\InetPub\Wwwroot\LearningASP\guestbook.mdb;"
'This creates an instance of an ADO Connection object.
'There are 4 other ADO objects available to you, each with different
methods and
'properties that allow you to do almost anything with database data.
Set objConn = server.createobject("ADODB.Connection")
'The Open method of the Connection object uses the connection string to
' create a connection to the database.
objConn.Open strProvider
'Define the query.
'There are many types of queries, allowing you to add, remove, or get data.
'This query will add your data into the database, using the INSERT INTO
key words.
'Here, Guestbook is the name of the table.
'You need single-quotes around strings here.
strCommand = "INSERT INTO Guestbook (FTB1,FTB2,FTB3,FTB4,FMB1) VALUES ('"
strCommand = strCommand & strTB1 & "','" & strTB2 & "','" & strTB3 & "','"
& strTB4 & "','" & strMB1
strCommand = StrCommand & "')"
'Execute the query to add the data into the database.
objConn.Execute strCommand
Response.Write("Thank you! Your data has been added.")
End if
%>
</font>
</body>
</html>
I copied and pasted it into a blank document after running into problems
when I manually entered the code for the first file, "Guestbook1.asp". Here
is the code from "Guestbook1.asp":
<%@ Language=VBScript %>
<html>
<head>
<title>Guest Book Using Connection Object Only</title>
</head>
<body>
<font face="arial">
<h2>Guest Book Using Connection Object Only</h2>
<%
If Not Request.QueryString("Message") = "True" Then
'No information has been input yet, so provide the form.
%>
<p>
<FORM NAME="GuestBook1" METHOD="GET" ACTION="guestbook1.asp">
<table>
<tr>
<td><font face="arial">From:</td><td><INPUT TYPE="TEXT"
NAME="From"></td>
</tr><tr>
<td><font face="arial">E-mail Address:</td><td><INPUT
TYPE="TEXT" NAME="EmailAdd"></td>
</tr><tr>
<td><font face="arial">CC:</td><td><INPUT TYPE="TEXT"
NAME="CC"><td>
</tr><tr>
<td><font face="arial">Subject:</td><td><INPUT TYPE="TEXT"
NAME="Subject"></td>
</tr>
</table>
Message: <br><TEXTAREA NAME="Memo" ROWS=6 COLS=70></TEXTAREA>
</p>
<p>
<INPUT TYPE="HIDDEN" NAME="Message" VALUE="TRUE">
<INPUT TYPE="SUBMIT" VALUE="Submit Information">
</FORM>
</p>
<%
Else
'The HIDDEN button above sets the Message variable to True.
'We know now that the form data has been entered.
'Get the data from the form. We will be inserting it into
the database.
'Access doesn't like some characters, such as
single-quotes, so encode the
' data using the HTMLEncode method of the ASP Server
object.
dim strTB1, strTB2, strTB3, strTB4, strMB1, strCommand
strTB1 = Server.HTMLEncode(Request.QueryString("From"))
strTB2 = Server.HTMLEncode(Request.QueryString("EmailAdd"))
strTB3 = Server.HTMLEncode(Request.QueryString("CC"))
strTB4 = Server.HTMLEncode(Request.QueryString("Subject"))
strMB1 = Server.HTMLEncode(Request.QueryString("Memo"))
'This is a connection string. ADO uses it to connect to a
database through the Access driver.
'It needs the provider name of the Access driver and the
name of the Access database.
'Connection strings are slightly different, depending on
the provided being used,
' but they all use semicolons to separate variables.
'If this line causes and error, search in your registry for
'Microsoft.JET to see if 4.0 is your version.
strProvider = "Provider=Microsoft.JET.OLEDB.4.0;Data
Source=C:\InetPub\Wwwroot\LearningASP\guestbook.mdb;"
'This creates an instance of an ADO Connection object.
'There are 4 other ADO objects available to you, each with
different methods and
'properties that allow you to do almost anything with
database data.
Set objConn = server.createobject("ADODB.Connection")
'The Open method of the Connection object uses the
connection string to
' create a connection to the database.
objConn.Open strProvider
'Define the query.
'There are many types of queries, allowing you to add,
remove, or get data.
'This query will add your data into the database, using the
INSERT INTO key words.
'Here, Guestbook is the name of the table.
'You need single-quotes around strings here.
strCommand = "INSERT INTO Guestbook
(FTB1,FTB2,FTB3,FTB4,FMB1) VALUES ('"
strCommand = strCommand & strTB1 & "','" & strTB2 & "','" &
strTB3 & "','" & strTB4 & "','" & strMB1
strCommand = StrCommand & "')"
'Execute the query to add the data into the database.
objConn.Execute strCommand
Response.Write("Thank you! Your data has been added.")
End if
%>
</font>
</body>
</html>
Like I said I first manually typed up Guestbook1.asp and for some reason,
the page would appear in IE, but after entering the fields, it wouldn't
upload the data to the Access file.
Opened another blank file and just copied and pasted the tutorial code into
it and named it Guestboo11.asp and changed the references to match the file
name as well as the location of the database and this one worled perfectly
fine!
I'm trying to understand where I went wrong. I tried to do a side-by-side
comparison without any luck.
Any advise or information for a poor sod trying to learning this stuff?
Thanks!
Manoj