Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


File Upload Option When Adding a New Record

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,64498
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> File Upload Option When Adding a New Record
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 File Upload Option When Adding a New Record - 9/23/2008 7:58:19 AM   
  arvinbocs

 

Posts: 1
Score: 0
Joined: 9/23/2008
Status: offline
I am working on a form that needs to be able to add record in the database and upload file at the same time. Is there a way of doing this? I was able to do a form that uploads files and updated records on a database but not together or as one. When I combine the two, it always fails. Please help. Here's my code:

UPDATERECORD.ASP
<html>
<head>
<title> Adding to database example </title>
<script type="text/javascript">
<!--
function validate()
{
if(document.form.title.value=="")
{
alert("Title is missing");
return false;
}
}
//-->
</script>
</head>
<body>
<form name="form" method="post" action="save.asp">
<p align="center"><b>Add Project Type:</b></p>
<table align="center" border=0 cellpadding=3 cellspacing=3 cols=2 width=400>
<tr>
<td align="right" height=10 valign="top">Num :</td>
<td align="left" height=10 valign="top" width=250><input type="text" name="num"/></td>
</tr>
<tr>
<td align="right" height=10 valign="top">Category :</td>
<td align="left" height=10 valign="top" width=250>
 <select name="category" size="1">
  <option value="Residential">Residential</option>
  <option value="Commercial/Industrial">Commercial/Industrial</option>
  <option value="Landfill/Overburden">Landfill/Overburden</option>
  <option value="Roadwork">Roadwork</option>
  <option value="Demolition">Demolition</option>
  <option value="Wetlands">Wetlands</option>
  <option value="Underground">Underground</option>
  <option value="Other">Other</option>
 </select>
</td>
</tr>
<tr>
<td align="right" height=10 valign="top">Title :</td>
<td align="left" height=10 valign="top" width=250><input type="text" name="title"/></td>
</tr>
<tr>
<td align="right" height=10 valign="top">File :</td>
<td align="left" height=10 valign="top" width=250><input type="file" name="elementName"/></td>
</tr>
<tr>
<td align="right" height=10 valign="top"></td>
<td align="left" height=10 valign="top" width=200><input type="submit" name="Save" value="Submit" onclick="return validate();"/></td>
</tr>
</table>
</form> 
</body>
</html>

SAVE.ASP
<%
Dim Conn
Dim Rs
Dim sql
'Create an ADO connection and recordset object
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
'Set an active connection and select fields from the database
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("category.mdb")
sql= "SELECT * FROM projtype;"
'Set the lock and cursor type
Rs.CursorType = 2
Rs.LockType = 3
'Open the recordset with sql query
Rs.Open sql, Conn   
'Prepare the database to add a new record and add
Rs.AddNew
Rs.Fields("num") = Request.Form("num")
Rs.Fields("category") = Request.Form("category")
Rs.Fields("title") = Request.Form("title")
'Save the update
Rs.Update  
Rs.Close
Set Rs = Nothing
Set Conn = Nothing
Response.Redirect "cmsprojectshowall.asp"
%>
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> File Upload Option When Adding a New Record Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts