<%
'-----------------------------------------------------------
'
'----------------------------------------------------------
' name: CreateOneRecordRecordset(soughtKeyValue)
'----------------------------------------------------------
Sub CreateOneRecordRecordset(soughtKeyValue)
'Declare constants for a recordset that allows adding records
'You can also just include the file ADOVBS.INC to get these constants
Const adLockOptimistic = 3
Const adOpenDynamic = 2
'Set the connection details
'Build the sql query used to fill the select element
sqlString = "select * from Specials where SpecialsID=" & soughtKeyValue
'Create a recordset
End Sub
'----------------------------------------------------------
' name: DrawPage
'----------------------------------------------------------
Sub DrawPage()
'Load recordset field values into local variables
SpecialsName = rs("SpecialsName") & ""
ImageName = rs("ImageName") & ""
%>
<html>
<head>
<title> Editing Pictures for Specials </title>
<p>
<P>
<p>
</head>
<body text="#000000" bgcolor="#ffffff" link="#006666" vlink="#999999" alink="#00cc33" background="toptxtr.gif">
<P align=center>
<SCRIPT LANGUAGE=JAVASCRIPT>
<!--
function InputIsValid()
{
//Check for missing file
if (document.frmSpecials.file.value == "")
{
alert("Please include the file.");
document.frmSpecials.file.focus();
return false;
}
//If it made it here, everything looks ok
return true;
}
// -->
</SCRIPT>
<FONT color=midnightblue size=7>Edit Specials</FONT></P>
<table>
<tr>
<td> </td>
</tr>
</table>
<FORM NAME="frmSpecials"
ACTION="EditSpecialsPic.asp" METHOD="post"
onSubmit="return InputIsValid()" ENCTYPE="multipart/form-data">
<TABLE width=400 align=center valign="top" cellpadding=2 cellspacing=0 border=0 bgcolor=#cccccc>
<TR>
<TD align=right><STRONG><font face=arial size=-1>Name</font></STRONG></TD>
<TD><%= SpecialsName %> </TD>
</TR>
<TR>
<TD align=right><STRONG><font face=arial size=-1> </font></STRONG></TD>
<TD align=center><img src=../images/<%= rs("ImageName") %> width=80 height=100 border=0></TD>
</TR>
<TR>
<TD align=right> </TD>
</TR>
<TR> <TD align="right"><STRONG><font face=arial size=-1>Image</font></STRONG></TD>
<TD width="70%"><INPUT TYPE="file" name="file" size="35"></TD></TR>
<tr>
<td align=right> </td>
<td align=middle>
<INPUT
Type=submit
Name=subSubmit Value="Submit"> <INPUT id=reset1 name=reset1 style="WIDTH: 74px; HEIGHT: 24px" type=reset value="Clear form">
</td>
</tr></TABLE><!-- Key value to pass along to the next page -->
<!-- Key value to pass along to the next page -->
<input type=hidden name=hidID value=<%= keyValue %> >
</FORM><!-- END OF FORM -->
</body>
</HTML>
<%
End Sub
'------------------------------------------
'END OF PROCEDURES AND START OF MAIN CODE
'------------------------------------------
dim rs
dim sqlString, KeyValue
dim connectionString, databaseName, physicalPath
dim SpecialsName
dim ImageName
'Get incoming key value
KeyValue = request.QueryString("ID")
'Create a one recordset with only the one
'desired record in it
Call CreateOneRecordRecordset(KeyValue)
'Draw the page
Call DrawPage()
'Close the recordset
%>
<%
Option Explicit
'===================================================================
' name: EditColor2.asp
'Procedures:
' CreateOneRecordRecordset(soughtKeyValue)
' UpdateRecord()
' ConvertEmptyToNull(theString)
' DrawPage()
'===================================================================
'----------------------------------------------------------
' name: CreateOneRecordRecordset(soughtKeyValue)
'----------------------------------------------------------
Sub CreateOneRecordRecordset(soughtKeyValue)
'Declare constants for a recordset that allows adding records
'You can also just include the file ADOVBS.INC to get these constants
Const adLockOptimistic = 3
Const adOpenDynamic = 2
dim connectionString, databaseName, path
dim sqlString
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
'Set connection details
'Build the sql query used to fill the select element
sqlString = "select * from Specials where SpecialsID=" & soughtkeyValue
'Create the recordset
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlString, connectionString, adOpenDynamic, adLockOptimistic
End Sub
'-------------------------------------------------------------
' name: UpdateRecord()
' description: Update the record
' note: This converts all empty strings to Null values
'--------------------------------------------------------------
Sub UpdateRecord()
' Upload
' ******
mySmartUpload.Upload
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Add the current file in a DB field
' **********************************
fic="images/" &file.FileName&""
file.SaveAs(fic)
Rs("ImageName") = file.FileName