Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting blobs in a database through a web form

Status
Not open for further replies.

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=&quot;WIDTH: 204px; HEIGHT: 70px&quot; name=txtNotes rows=4 cols=22 scrolling=&quot;auto&quot;></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=&quot;Submit Doc&quot;>&nbsp;
<INPUT id=reset1 name=reset1 type=reset value=&quot;Clear Form&quot;>

<p></FORM>




and the SubmitTechDoc.asp




<%
sub DisplayConfirmation
dim str
str = &quot;Document '&quot; + Request.Form.Item(&quot;txtTitle&quot;) + &quot;' has been successfully written to the database. &quot;
Response.Write(str)
Response.Write(&quot;Press your browser's Back button to return to add more Contacts&quot;)
end sub

sub WriteRecord
dim strInsertSql
dim commandObject

Set DatabaseConnection = Server.CreateObject(&quot;ADODB.Connection&quot;)
DatabaseConnection.Open &quot;DSN=RFSTPdatabase&quot;, &quot;sa&quot;, &quot;knight&quot;

set commandObject=Server.CreateObject(&quot;ADODB.Command&quot;)
set commandObject.ActiveConnection=DatabaseConnection

strInsertSql = &quot;insert into TechDocs(TITLE, Author, ID, subject, CourseID, notes, pages, Publisher, Document, Date_year)&quot;
strInsertSql = strInsertSql + &quot; values(&quot;

strInsertSql = strInsertSql + &quot;'&quot; + Request.Form.Item(&quot;txtTitle&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;txtAuthor&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;txtID&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;txtSubject&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;txtCourseID&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;txtnotes&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;txtpages&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;txtPublisher&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;imgDocument&quot;) + &quot;',&quot;
strInsertSql = strInsertSql + &quot; '&quot; + Request.Form.Item(&quot;txtdate_year&quot;) + &quot;'&quot;
strInsertSql = strInsertSql + &quot;)&quot;

'Response.Write(strInsertSql)

commandObject.CommandText = strInsertSql
commandObject.Execute

DatabaseConnection.Close
end sub


if Request.Form.Count <= 0 then
Response.Write(&quot;You have entered this form incorrectly. This page is only accessable from the update_techdoc.asp page.&quot;)
else
Call WriteRecord
Call DisplayConfirmation
end if
%>





I hope someone will be kind enough to help me.

regards


Antonio Maria Giorgi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top