Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : ASP : ASP 3.0 : saving file to disk and other fields to access database Signup · Login
Author Thread
saving file to disk and other fields to access database
Posted in tutorial: Uploading Files to the Server Hard Disk using plain ASP
·  sanim16
User
Joined: 1 Feb 2006
Total Posts: 3
saving file to disk and other fields to access database
Posted: 20 Mar 2006
i modified the code for insert to save some of the info to a database while still saving the file to the server.
i used the load.getvalue to access the other formfields as prescribed.

and the code to save it is as follows
<%
If fileUploaded = True Then
' Checking to make sure if file was uploaded
If fileSize > 0 Then

' Connection string
Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
connStr = connStr & Server.MapPath("The_Pawn_Box.mdb")

' Recordset object
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open "Products Info", connStr, 2, 2

' Adding data
rs.AddNew
rs("Name") = wants_to_sell
rs("Category") = category
rs("Username") = username
rs("Emailaddress") = emailaddress
rs("HomePhone") = homephone
rs("MobileNumber") = mobilephone
rs("Classification") = classification
rs("SubClass") = subclass
rs("Age") = age
rs("Price") = price
rs("BriefDescription") = briefdescription
rs("State") = selstate
rs("Pic") = pic
rs.Update

rs.Close
Set rs = Nothing

Response.Write "<p align=""center"">"
Response.Write "<font color=""green"">File and info were successfully uploaded..."
Response.Write "</font>"
Response.Write "</p>"
Else
' Connection string
' Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
connStr = connStr & Server.MapPath("The Pawn Box.mdb")

' Recordset object
'Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

rs.Open "Products Info", connStr, 2, 2

' Adding data
rs.AddNew
rs("Name") = wants_to_sell
rs("Category") = category
rs("Username") = username
rs("Emailaddress") = emailaddress
rs("HomePhone") = homephone
rs("MobileNumber") = mobilephone
rs("Classification") = classification
rs("SubClass") = subclass
rs("Age") = age
rs("Price") = price
rs("BriefDescription") = briefdescription
rs("State") = selstate
rs("Pic") = "uploaded/" & category & ".gif"
rs.Update

rs.Close
Set rs = Nothing

Response.Write "<p align=""center"">"
Response.Write "<font color=""brown"">No file was selected for uploading but Ad details were placed"
Response.Write "...</font>"
Response.Write "</p>"
End If
else
Response.Write "<p align=""center"">"
Response.Write "<font color=""red"">File could not be uploaded..."
Response.Write "</font>"
Response.Write "<br>Please select a file before hitting the 'Submit'"
Response.Write " button."
Response.Write "</p>"
End If

If Err.number <> 0 Then
Response.Write "<p align=""center"">"
Response.Write "<br><font color=""red"">Something went wrong..."
Response.Write "</font>"
Response.Write "</p>"
End If
Response.Write fileName & " data uploaded..."
%>


this gives the corresponding error

Microsoft JET Database Engine error '80040e14'

Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.


Users Who Have Visited This Thread In Last 24 Hours
2 Visitors

Login
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.