Forums

This topic is locked

Dreamweaver 8 ASP problems writing to access db

Posted 01 Apr 2008 21:32:24
1
has voted
01 Apr 2008 21:32:24 Mike Anderson posted:
I created a page to upload a file and write to an access db (mdb). I am using Dreamweaver 8, Access 2007 (saved as .mdb), ASP Upload 3, and Image Processor 2.0.3. I also have a login page, etc.

The connection string to the db works fine. I can login and get to the upload page. The page uploads the image and resizes it without a problem, but it does not write to the database and I can't figure out why. It does not give me an error (no permissions or db connection problems), it just will not write to the db. I typically use SQL, but this client wants Access. Any suggestions? Here is the code on the upload page.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/ftbelvoir.asp" -->
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="login.asp"
MM_grantAccess=false
If Session("MM_Username" <> "" Then
If (true Or CStr(Session("MM_UserAuthorization")="" Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization")>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?" >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL"
if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
<!--#include file="../ScriptLibrary/incSIP2Class.asp" -->
<!--#include file="../ScriptLibrary/incPU3Class.asp" -->
<!--#include file="../ScriptLibrary/incPU3Utils.asp" -->
<%
'*** Pure ASP File Upload 3.0.9
' Process form form1
Dim pau, DMX_uploadAction, UploadRequest, UploadQueryString, pau_thePath, pau_nameConflict, pau_saveWidth, pau_saveHeight
Set pau = new PureUpload
pau.ScriptLibrary = "../ScriptLibrary"
pau.ConflictHandling = "uniq"
pau.StoreType = "file"
pau.ProgressTemplate = "win_look.htm"
pau.ProgressWidth = 400
pau.ProgressHeight = 200
pau.UploadFolder = """../gallery"""
pau.AllowedExtensions = "GIF,JPG,JPEG,BMP,PNG" ' "images"
pau.ProcessUpload
pau.SaveAll
if pau.Done then Response.Redirect "galleryadmin.asp"
%>
<%
' Smart Image Processor 2.0.3
Dim sip1
Set sip1 = New ImageProcessor
sip1.ScriptFolder = "../ScriptLibrary"
sip1.Component = "Auto"
sip1.Source = "upload"
sip1.UploadFields = ""
sip1.GetFiles
While sip1.HasFiles
sip1.LoadFromSource
sip1.Resize 450, 450, true
sip1.Overwrite = true
sip1.SaveJPEG 80
sip1.MoveNext
Wend
Set sip1 = Nothing
If (CStr(Request.QueryString("GP_upload") <> "" Then
Response.Redirect "galleryadmin.asp"
End If
%>
<%
' Smart Image Processor 2.0.3
Dim sip2
Set sip2 = New ImageProcessor
sip2.ScriptFolder = "../ScriptLibrary"
sip2.Component = "Auto"
sip2.Source = "upload"
sip2.UploadFields = ""
sip2.GetFiles
While sip2.HasFiles
sip2.LoadFromSource
sip2.Resize 150, 150, true
sip2.Overwrite = false
sip2.Mask = "##path####name##_small.jpg"
sip2.SaveJPEG 80
sip2.MoveNext
Wend
Set sip2 = Nothing
%>
<%
' *** Edit Operations: (Modified for File Upload) declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (UploadQueryString <> "" Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(UploadQueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: (Modified for File Upload) set variables

If (CStr(UploadFormRequest("MM_insert") = "form1" Then

MM_editConnection = MM_ftbelvoir_STRING
MM_editTable = "Gallery"
MM_editRedirectUrl = "galleryadmin.asp"
MM_fieldsStr = "ImageName|value|ImageDescription|value|ImagePath|value"
MM_columnsStr = "ImageName|',none,''|ImageDescription|',none,''|ImagePath|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(UploadFormRequest(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And UploadQueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
End If
End If

End If
%>
<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(UploadFormRequest("MM_insert") <> "" Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none" Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none" Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none" Then MM_emptyVal = ""
If (MM_formVal = "" Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "" Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'" Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''" & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="../includes/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"><%=pau.generateScriptCode()%></script>
<script src="../ScriptLibrary/incPU3.js" type="text/javascript"></script>
</head>

<body>
<form action="<%=MM_editAction%>" method="POST" enctype="multipart/form-data" name="form1" id="form1" onSubmit="<%=pau.submitCode()%>;return document.MM_returnValue">
<p> </p>
<p> </p>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr>
<td colspan="2" bgcolor="#FFFFFF"><div align="center">
<p><strong>Add Gallery Image <br />
</strong><a href="addgallery.asp">Add Gallery Image</a> | <a href="addpartner.asp">Add Partner</a> | <a href="checklist.asp">Update Checklist</a><br />
<a href="galleryadmin.asp">Manage Gallery</a> | <a href="partneradmin.asp">Manage Partners</a> </p>
<p><br />
</p>
</div></td>
</tr>
<tr>
<td width="37%" bgcolor="#FFFFFF"><div align="right">Image Name: </div></td>
<td width="63%" bgcolor="#FFFFFF"> <input name="ImageName" type="text" id="ImageName" /></td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFFF"><div align="right">Description: </div></td>
<td bgcolor="#FFFFFF"><textarea name="ImageDescription" cols="40" rows="8" id="ImageDescription"></textarea></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><div align="right">Image to Upload: </div></td>
<td bgcolor="#FFFFFF"><input name="ImagePath" type="file" id="ImagePath" onChange="<%=pau.validateCode()%>;return document.MM_returnValue" /></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"><label>
<input name="Upload" type="submit" id="Upload" value="Upload" />
</label></td>
</tr>
</table></td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>

Replies

Replied 03 Apr 2008 17:59:23
03 Apr 2008 17:59:23 Clifford Rizzo replied:
Make sure that the share options have correct permissions.

Reply to this topic