Guest_imported
New member
- Jan 1, 1970
- 0
Hi, can someone please tell me what I should change in this code.
The form below uploads all records in teh database but not the BLOB file in teh column named 'Document'( which is a image datatype column and, if accessed with MS Access correctly stores binary files)
. Help, I am stuck!
My form:
<FORM name=update_techdoc method=post action=SubmitTechDoc.asp>
<TABLE>
<TR><TD>Title:</TD>
<TD><INPUT id=txtTitle name=txtTitle></TD></TR>
<TR><TD>Author:</TD>
<TD><INPUT id=txtAuthor name=txtAuthor></TD></TR>
<TR><TD>ID:</TD>
<TD><INPUT id=txtID name=txtID></TD></TR>
<TR><TD>Subject:</TD>
<TD><INPUT id=txtSubject name=txtSubject></TD></TR>
<TR><TD>CourseID:</TD>
<TD><INPUT id=txtCourseID name=txtCourseID></TD></TR>
<TR><TD>Notes:</TD>
<TD><TEXTAREA id=txtNotes style="WIDTH: 204px; HEIGHT: 70px" name=txtNotes rows=4 cols=22 scrolling="auto"></TEXTAREA></TD></TR>
<TR><TD>Pages:</TD>
<TD><INPUT id=txtPages name=txtPages></TD></TR>
<TR><TD>Publisher:</TD>
<TD><INPUT id=txtPublisher name=txtPublisher></TD></TR>
<TR><TD>Document:</TD>
<TD><INPUT type=file id=imgDocument name=imgDocument></TD></TR>
<TR><TD>Date:</TD>
<TD><INPUT id=txtDate_year name=txtDate_year></TD></TR>
</TABLE></FONT></P>
</DIV><INPUT id=submit1 name=submit1 type=submit value="Submit Doc">
<INPUT id=reset1 name=reset1 type=reset value="Clear Form">
<p></FORM>
and the SubmitTechDoc.asp
<%
sub DisplayConfirmation
dim str
str = "Document '" + Request.Form.Item("txtTitle" + "' has been successfully written to the database. "
Response.Write(str)
Response.Write("Press your browser's Back button to return to add more Contacts"
end sub
sub WriteRecord
dim strInsertSql
dim commandObject
Set DatabaseConnection = Server.CreateObject("ADODB.Connection"
DatabaseConnection.Open "DSN=RFSTPdatabase", "sa", "knight"
set commandObject=Server.CreateObject("ADODB.Command"
set commandObject.ActiveConnection=DatabaseConnection
strInsertSql = "insert into TechDocs(TITLE, Author, ID, subject, CourseID, notes, pages, Publisher, Document, Date_year)"
strInsertSql = strInsertSql + " values("
strInsertSql = strInsertSql + "'" + Request.Form.Item("txtTitle" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtAuthor" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtID" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtSubject" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtCourseID" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtnotes" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtpages" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtPublisher" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("imgDocument" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtdate_year" + "'"
strInsertSql = strInsertSql + ""
'Response.Write(strInsertSql)
commandObject.CommandText = strInsertSql
commandObject.Execute
DatabaseConnection.Close
end sub
if Request.Form.Count <= 0 then
Response.Write("You have entered this form incorrectly. This page is only accessable from the update_techdoc.asp page."
else
Call WriteRecord
Call DisplayConfirmation
end if
%>
I hope someone will be kind enough to help me.
regards
Antonio Maria Giorgi
The form below uploads all records in teh database but not the BLOB file in teh column named 'Document'( which is a image datatype column and, if accessed with MS Access correctly stores binary files)
. Help, I am stuck!
My form:
<FORM name=update_techdoc method=post action=SubmitTechDoc.asp>
<TABLE>
<TR><TD>Title:</TD>
<TD><INPUT id=txtTitle name=txtTitle></TD></TR>
<TR><TD>Author:</TD>
<TD><INPUT id=txtAuthor name=txtAuthor></TD></TR>
<TR><TD>ID:</TD>
<TD><INPUT id=txtID name=txtID></TD></TR>
<TR><TD>Subject:</TD>
<TD><INPUT id=txtSubject name=txtSubject></TD></TR>
<TR><TD>CourseID:</TD>
<TD><INPUT id=txtCourseID name=txtCourseID></TD></TR>
<TR><TD>Notes:</TD>
<TD><TEXTAREA id=txtNotes style="WIDTH: 204px; HEIGHT: 70px" name=txtNotes rows=4 cols=22 scrolling="auto"></TEXTAREA></TD></TR>
<TR><TD>Pages:</TD>
<TD><INPUT id=txtPages name=txtPages></TD></TR>
<TR><TD>Publisher:</TD>
<TD><INPUT id=txtPublisher name=txtPublisher></TD></TR>
<TR><TD>Document:</TD>
<TD><INPUT type=file id=imgDocument name=imgDocument></TD></TR>
<TR><TD>Date:</TD>
<TD><INPUT id=txtDate_year name=txtDate_year></TD></TR>
</TABLE></FONT></P>
</DIV><INPUT id=submit1 name=submit1 type=submit value="Submit Doc">
<INPUT id=reset1 name=reset1 type=reset value="Clear Form">
<p></FORM>
and the SubmitTechDoc.asp
<%
sub DisplayConfirmation
dim str
str = "Document '" + Request.Form.Item("txtTitle" + "' has been successfully written to the database. "
Response.Write(str)
Response.Write("Press your browser's Back button to return to add more Contacts"
end sub
sub WriteRecord
dim strInsertSql
dim commandObject
Set DatabaseConnection = Server.CreateObject("ADODB.Connection"
DatabaseConnection.Open "DSN=RFSTPdatabase", "sa", "knight"
set commandObject=Server.CreateObject("ADODB.Command"
set commandObject.ActiveConnection=DatabaseConnection
strInsertSql = "insert into TechDocs(TITLE, Author, ID, subject, CourseID, notes, pages, Publisher, Document, Date_year)"
strInsertSql = strInsertSql + " values("
strInsertSql = strInsertSql + "'" + Request.Form.Item("txtTitle" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtAuthor" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtID" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtSubject" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtCourseID" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtnotes" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtpages" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtPublisher" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("imgDocument" + "',"
strInsertSql = strInsertSql + " '" + Request.Form.Item("txtdate_year" + "'"
strInsertSql = strInsertSql + ""
'Response.Write(strInsertSql)
commandObject.CommandText = strInsertSql
commandObject.Execute
DatabaseConnection.Close
end sub
if Request.Form.Count <= 0 then
Response.Write("You have entered this form incorrectly. This page is only accessable from the update_techdoc.asp page."
else
Call WriteRecord
Call DisplayConfirmation
end if
%>
I hope someone will be kind enough to help me.
regards
Antonio Maria Giorgi