If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Store filepath for files in a folder in a accessdatabase

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-10-05, 04:23
Td04 Td04 is offline
Registered User
 
Join Date: Mar 2004
Posts: 52
Question Store filepath for files in a folder in a accessdatabase

I want to store filename/path and date for all files in a special images folder.
I try to use the filesystem object and it reads up all files but when i submit I get a error.
I put the insert into in the loop statement but I get a error msg:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
/updateDb.asp, line 49

Any ideas about this?
Thanks!/Martin

Code:
IF request.form ("Message")="True" THEN
Session.LCID = 1053
strURL = Request.ServerVariables("URL")
bildUrl="http://s14/Images/"
	strProvider="Driver=Microsoft Access Driver (*.mdb); DBQ=d:\Images.mdb;"
	set objConn = server.createobject("ADODB.Connection")
    objConn.Open strProvider
	set cm = Server.CreateObject("ADODB.Command")
	cm.ActiveConnection = objConn
	
end if
%>
<Table><tr>
<td><form name="files" action="<%= strURL %>" method="post">
<select name="search" class="list" size="20">
<%
'create file list
x=0
Dim objFileScripting, objFolder
    Dim filename, filecollection, strDirectoryPath, strUrlPath
    	strDirectoryPath="D:\Images"
    	strUrlPath="http:\\s14\Images"
    	Set objFileScripting = CreateObject("Scripting.FileSystemObject")
       	Set objFolder = objFileScripting.GetFolder("D:\Images")
    	Set filecollection = objFolder.Files
    	'go thru recs
For Each Filename In filecollection
    		Filename=right(Filename,len(Filename)-InStrRev(Filename, "\"))
			Fileval = left(Filename, len(Filename)-4)
			Fileval=Replace(Fileval,"$","/")
			x=x+1
		    IF request.form ("Message")="True" THEN
			cm.CommandText ="INSERT INTO ImageTable(Image,Date) VALUES (?,?)" 
			set objparam=cm.createparameter(, 200, , 255,bildUrl&Filename)
			cm.parameters.append objparam
			set objparam=cm.createparameter(, 200, , 255, Date)
			cm.parameters.append objparam
			end if
			%><!--<option value="<%=filename%>"><%=fileval%></option>--><%
			IF request.form ("Message")="True" THEN
			cm.execute
  			Set objparam = Nothing
  			'cm.delete
			end if
	    	Next
			%>
</select></td></tr>
<tr>
<td><input type="submit" style="font-family: Tahoma; font-size: 10pt;"></td>
<input  type="HIDDEN" name="Message" value="True">
</tr></table>
</form>
__________________
"Never underestimate a large number of morons"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On