Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: images to access db errors and confusion!


Message #1 by "Katrina Flaws" <kflaws@w...> on Wed, 10 Jul 2002 17:47:22
Hello:

Please help me, Ive got two pages to view, I have cut and paste some code 
from 4GUYs to be able to upload images to a database. Im getting an error 
on the rs:
Provider error '80020005' 

Type mismatch. 

/aspagent/addhomeconfirm.asp, line 30

I have dealt with this type of error in the past but am at a loss right 
now, I have too much code going through my head and getting confused!! 
Here are the pages Im working with:
<!--
'Addhome.asp
'Katrina Flaws-WRD
'June 21, 2002
-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Addhome.asp</TITLE>
</HEAD>
<BODY bgcolor="#E7EEC5" text="#333333"><center>
  <table height="369">
      <form name="frmInput" action="/aspagent/addhomeconfirm.asp" 
enctype="multipart/form-data" method="post">
      <tr> 
        <td height="74" colspan="2" valign="top"> 
          <h1 align="center"><img src="/images/newlogo.gif" width="150" 
height="100" alt="Foxfire Logo"></h1>
          <h1 align="center">Add New Home</h1>
        </td>
      </tr>
      <tr> 
        <td width="216"><b><font face="Verdana, Arial, Helvetica, sans-
serif">MLS 
          Number</font></b></td>
        <td width="141"> 
          <input type="text" name="MLS" size="20" maxlength="100">
        </td>
      </tr>
      <tr> 
        <td><b><font face="Verdana, Arial, Helvetica, sans-serif">Number 
of Acres</font></b></td>
        <td> 
          <input type="text" name="Acres" size="20" maxlength="100">
        </td>
      </tr>
      <tr> 
        <td height="85"><b><font face="Verdana, Arial, Helvetica, sans-
serif">List_Description 
          of Home</font></b></td>
        <td height="85"> 
          <textarea name="List_Description" cols="20"></textarea>
        </td>
      </tr>
      <tr> 
        <td><b><font face="Verdana, Arial, Helvetica, sans-serif">Number 
of Stories</font></b></td>
        <td> 
          <input type="text" name="Stories" size="20" maxlength="100">
        </td>
      </tr>
      <tr> 
        <td><b><font face="Verdana, Arial, Helvetica, sans-serif">Number 
of Bedrooms</font></b></td>
        <td> 
          <input type="text" name="Bedrooms" size="20" maxlength="100">
        </td>
      </tr>
      <tr> 
        <td><b><font face="Verdana, Arial, Helvetica, sans-serif">Number 
of Bathrooms</font></b></td>
        <td> 
          <input type="text" name="Bathrooms" size="20" maxlength="100">
        </td>
      </tr>
      <tr> 
        <td><b><font face="Verdana, Arial, Helvetica, sans-
serif">Location of 
          Home</font></b></td>
        <td> 
          <input type="text" name="Location" size="20" maxlength="100">
        </td>
      </tr>
      <tr> 
        <td valign="top" height="32"><b><font face="Verdana, Arial, 
Helvetica, sans-serif"> 
          Price of Home</font></b></td>
        <td valign="top"> 
          <input type="text" name="Price" size="20" maxlength="100">
        </td>
      </tr>
      <tr>
        <td><font face="Verdana, Arial, Helvetica, sans-
serif"><b>File :</b></font></td>
        <td>
		<input type="file" name="file" size="40"></td></tr>
	
      <tr> 
        <td colspan="2" align="center" height="99"> 
          <p> 
            <input type="submit" name="ShowInfo" value="submit">
          </p>
          <p><font color="#FF0000">(Notice: All fields must have values, 
<br>
            otherwise you will get an error message.) </font></p>
        </td>
      </tr>
    </form>
  </table>

 
 
<!--#include virtual="/aspagent/navigation.htm" -->
  
</center>
</BODY>
</HTML>

Now page two------------------------------------------------------------
<%
Option Explicit
%>
<!--#include virtual="/adovbs.asp" -->
<!--#include file="Loader.asp"-->
<%
Dim connectionString, rs, sql, databaseName, path
Dim cn ,selection, intRowColor
Dim MLS, Acres, List_Description, Stories, count 
Dim Bedrooms, Bathrooms, Price, Location

Sub AddNew()

set cn=server.CreateObject("ADODB.Connection")
CN.Open "accessDSN"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open "Select * From residentialhomes", CN, adOpenStatic, 
adLockOptimistic

rs.AddNew
MLS = Request.Form("MLS")
Stories = Request.Form("Stories")
Price = Request.Form("Price")
Location = Request.Form("Location")
Bedrooms = Request.Form("Bedrooms")
Bathrooms = Request.Form("Bathrooms")
List_Description = Request.Form("List_Description")
Acres = Request.Form("Acres")

'put values in rs
rs("MLS") = MLS & " "
rs("Stories") = Stories & " "
rs("Price") = Price & " " 
rs("Location") = Location & " " 
rs("Bedrooms") = Bedrooms & " " 
rs("Bathrooms") = Bathrooms & " " 
rs("List_Description") = List_Description & " " 
rs("Acres") = Acres & " " 

rs.Update

rs.Close
Set rs = Nothing

End Sub

Sub DrawPage()

  Response.Buffer = True

  ' load object
  Dim load
    Set load = new Loader
    
    ' calling initialize method
    load.initialize
    
  ' File binary data
  Dim fileData
    fileData = load.getFileData("file")
  ' File name
  Dim fileName
    fileName = LCase(load.getFileName("file"))
  ' File path
  Dim filePath
    filePath = load.getFilePath("file")
  ' File path complete
  Dim filePathComplete
    filePathComplete = load.getFilePathComplete("file")
  ' File size
  Dim fileSize
    fileSize = load.getFileSize("file")
  ' File size translated
  Dim fileSizeTranslated
    fileSizeTranslated = load.getFileSizeTranslated("file")
  ' Content Type
  Dim contentType
    contentType = load.getContentType("file")
  ' No. of Form elements
  Dim countElements
    countElements = load.Count
        
  ' destroying load object
  Set load = Nothing
%>


<html>
<head></head><body bgcolor="#E7EEC5">
<center>
  <h1><img src="/images/newlogo.gif" width="150" height="100"></h1>
  <h1><%= MLS %> at location &nbsp;<%= location %>&nbsp;was added to the 
residential homes database 
    on:<%= Date %> at <%= Time %></h1>
</center>
<center>
  


 <p style="padding-left:220;">
  <%= fileName %> data received ...<br>
  <%
    ' 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("foxfire.mdb")
    
      ' Recordset object
      Dim rs
        Set rs = Server.CreateObject("ADODB.Recordset")
        
        rs.Open "residentialhomes", connStr, 2, 2
        
        ' Adding data
        rs.AddNew
          rs("File Name") = fileName
          rs("File Size") = fileSize
          rs("File Data").AppendChunk fileData
          rs("Content Type") = contentType
          
		  rs.Update
        
        rs.Close
        Set rs = Nothing
        
      Response.Write "<font color=""green"">File was successfully 
uploaded..."
      Response.Write "</font>"
    Else
      Response.Write "<font color=""brown"">No file was selected for 
uploading"
      Response.Write "...</font>"
    End If
      
      
    If Err.number <> 0 Then
      Response.Write "<br><font color=""red"">Something went wrong..."
      Response.Write "</font>"
    End If
  %>
<!--#include virtual="/aspagent/navigation.htm" -->   
</center>
</body>
</html>

<%

End Sub

Call AddNew()
Call DrawPage()

%>


THANK YOU ANYONE WHO CAN HELP ME WITH THIS!!!!!!!!!!!!!

  Return to Index