Forums

This topic is locked

SQL problem

Posted 01 Jun 2002 05:04:43
1
has voted
01 Jun 2002 05:04:43 Tolu Ayoola posted:
Alright, I'm designing a page where users can delete their picture (the real file) and I want to be able to update the database field as soon as it deletes the picture file but I don't know how to do it. Can someone please help?

here's what i have so far.

editprofile.asp ---> sends a string called "img" to deleleProfilePicture.asp and deleteProfilePicture.asp is searches through the recordset and delete the file and I WANT IT TO UPDATE THE img field in the database so it will be empty. I'm getting an error saying the UPDATE statement is not correct.

Here is the code I have on deleteProfilePicture.asp. Can someone please help?

----------------------------------------


< %@LANGUAGE="VBSCRIPT"% >

< %

if(Request.QueryString("img" <> "" then cmPicture__Img = Request.QueryString("img"

% >
< %
Dim rsdel__idq
rsdel__idq = "1"
if (Request.QueryString("img" <> "" then rsdel__idq = Request.QueryString("img"
% >
< %
set rsdel = Server.CreateObject("ADODB.Recordset"
rsdel.ActiveConnection = MM_cnAdmMemNewPicSpon_STRING
rsdel.Source = "SELECT img FROM Members WHERE img = '" + Replace(rsdel__idq, "'", "''" + "'"
rsdel.CursorType = 0
rsdel.CursorLocation = 2
rsdel.LockType = 3
rsdel.Open()
rsdel_numRows = 0
% >
< %
dim ver
ver = Request.QueryString("img"
if ver <> "" then

dim num
dim xide
dim whr
dim sql

Function newFileSystemObject()
set newFileSystemObject=Server.CreateObject("Scripting.FileSystemObject"
End Function

Function fileExists(aFileSpec)
fileExists=newFileSystemObject.FileExists(aFileSpec)
End Function

' This is where we delete the file before we delete the record!
Set File = CreateObject("Scripting.FileSystemObject"
ImagePath = Server.MapPath("pics"
ImagePath = ImagePath & "/" & (rsdel.Fields.Item("img".Value)
' check if file exists and if true delete the file
If fileExists(ImagePath) Then
File.DeleteFile(ImagePath)
End If

% >
< %

set cmPicture = Server.CreateObject("ADODB.Command"
cmPicture.ActiveConnection = MM_cnAdmMemNewPicSpon_STRING
cmPicture.CommandText = "UPDATE Members SET " + Replace(cmPicture__Img, "'", "''" + " = '"" WHERE " + Replace(cmPicture__Img, "'", "''" + " = '" + Replace(cmPicture__Img, "'", "''" + "' "
cmPicture.CommandType = 1
cmPicture.CommandTimeout = 0
cmPicture.Prepared = true
cmPicture.Execute()

% >
< % Response.Redirect("editPictures.asp"% >
< %
else
Response.write "<span class=""textbold"">Missing checkbox detected  <a href=""javascript:history.back(1)""</span>Go back</a>"
end if
% >
< %
rsdel.Close()
%>


The initial fright of failure is the beginning of failure itself -Tolu

Replies

Replied 02 Jun 2002 21:29:38
02 Jun 2002 21:29:38 Tolu Ayoola replied:
nevermind.. i figured it out

The initial fright of failure is the beginning of failure itself -Tolu

Reply to this topic