Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: Insert Into?

  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Insert Into?

    I am having problems, please can someone help me?!
    I am using AspSmartUpload to upload a file.filname to my uploads folder, I want to grab that file.filename and put it into my access database
    the code I am using for that at the moment is below
    Code:
    Conn.Execute("insert into pics1 set rspic = '" & (file.filename) & "' where author = '" & session("variable") & "'")
    the error message is: Microsoft VBScript runtime error '800a01a8'

    Object required: ''

    /johnny/upload.asp, line 195

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    response.write out the quary, and see what your gettins first,

    SQL = ("insert into pics1 set rspic = '" & (file.filename) & "' where author = '" & session("variable") & "'")
    response.write SQL
    response.end

    Conn.Execute(SQL)


    and post back the writen out insert statement.

    -Ken

  • #3
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I pit in the SQL and the response.write part and uploaded on the next screen i got: insert into pics1 set rspic = 'ipod.JPG' where author = ''

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ok,
    so the problem is here:
    session("variable")

    looks like this session value isn't set.
    check your value names, and try setting the session again,
    or making it static, like
    session("variable") = "24"
    or whatever it should be.

    -Ken

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks!

    yes ok so I changed variable to what the variable is and now it shows that the author is Admin (me) so why does it still not go into the database?

  • #6
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    I'm assuming that conn really is a connection object?

  • #7
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know what the connection object is?!

  • #8
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ok,
    did u remove the response.end?

    SQL = ("insert into pics1 set rspic = '" & (file.filename) & "' where author = '" & session("variable") & "'")
    Conn.Execute(SQL)

    that should do it.

    -Ken

  • #9
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes that SHOULD o it but now I get

    Microsoft VBScript runtime error '800a01a8'

    Object required: ''

    /johnny/upload.asp, line 178

    Line 178
    Code:
    Conn.Execute(SQL)
    is this because I am using a multiple upload?

  • #10
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    can u post the whole script, including the connection string? just xxx out any server and login info.

    -Ken

  • #11
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    upload.asp
    Code:
    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="Connections/xxx.asp" -->
    <%
    ' *** Edit Operations: declare variables
    
    Dim MM_editAction
    Dim MM_abortEdit
    Dim MM_editQuery
    Dim MM_editCmd
    
    Dim MM_editConnection
    Dim MM_editTable
    Dim MM_editRedirectUrl
    Dim MM_editColumn
    Dim MM_recordId
    
    Dim MM_fieldsStr
    Dim MM_columnsStr
    Dim MM_fields
    Dim MM_columns
    Dim MM_typeArray
    Dim MM_formVal
    Dim MM_delim
    Dim MM_altVal
    Dim MM_emptyVal
    Dim MM_i
    
    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
      MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
    End If
    
    ' boolean to abort record edit
    MM_abortEdit = false
    
    ' query string to execute
    MM_editQuery = ""
    %>
    <%
    ' *** Insert Record: set variables
    
    If (CStr(Request("MM_insert")) = "form1") Then
    
      MM_editConnection = MM_tis_STRING
      MM_editTable = "pics1"
      MM_editRedirectUrl = "thanks.asp"
      MM_fieldsStr  = "rsPic|value"
      MM_columnsStr = "rsPic|',none,''"
    
      ' create the MM_fields and MM_columns arrays
      MM_fields = Split(MM_fieldsStr, "|")
      MM_columns = Split(MM_columnsStr, "|")
      
      ' set the form values
      For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
        MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
      Next
    
      ' append the query string to the redirect URL
      If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
        If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
          MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
        Else
          MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
        End If
      End If
    
    End If
    %>
    <%
    ' *** Insert Record: construct a sql insert statement and execute it
    
    Dim MM_tableValues
    Dim MM_dbValues
    
    If (CStr(Request("MM_insert")) <> "") Then
    
      ' create the sql insert statement
      MM_tableValues = ""
      MM_dbValues = ""
      For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
        MM_formVal = MM_fields(MM_i+1)
        MM_typeArray = Split(MM_columns(MM_i+1),",")
        MM_delim = MM_typeArray(0)
        If (MM_delim = "none") Then MM_delim = ""
        MM_altVal = MM_typeArray(1)
        If (MM_altVal = "none") Then MM_altVal = ""
        MM_emptyVal = MM_typeArray(2)
        If (MM_emptyVal = "none") Then MM_emptyVal = ""
        If (MM_formVal = "") Then
          MM_formVal = MM_emptyVal
        Else
          If (MM_altVal <> "") Then
            MM_formVal = MM_altVal
          ElseIf (MM_delim = "'") Then  ' escape quotes
            MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
          Else
            MM_formVal = MM_delim + MM_formVal + MM_delim
          End If
        End If
        If (MM_i <> LBound(MM_fields)) Then
          MM_tableValues = MM_tableValues & ","
          MM_dbValues = MM_dbValues & ","
        End If
        MM_tableValues = MM_tableValues & MM_columns(MM_i)
        MM_dbValues = MM_dbValues & MM_formVal
      Next
      MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
    
      If (Not MM_abortEdit) Then
        ' execute the insert
        Set MM_editCmd = Server.CreateObject("ADODB.Command")
        MM_editCmd.ActiveConnection = MM_editConnection
        MM_editCmd.CommandText = MM_editQuery
        MM_editCmd.Execute
        MM_editCmd.ActiveConnection.Close
    
        If (MM_editRedirectUrl <> "") Then
          Response.Redirect(MM_editRedirectUrl)
        End If
      End If
    
    End If
    %>
    <HTML>
    <style type="text/css">
    <!--
    .style1 {
    	font-size: 12px;
    	font-weight: bold;
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	color: #FF0000;
    }
    .style2 {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 12px;
    }
    .style3 {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: 14px;
    }
    -->
    </style>
    <BODY BGCOLOR="white">
    
    <H1 class="style2">Upload a pic! </H1>
    <HR>
    
    <p class="style3">
      <%
    '  Variables
    '  *********
       Dim mySmartUpload
       Dim file
       Dim intCount
       intCount=0
            
    '  Object creation
    '  ***************
       Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
    
    '  Upload
    '  ******
       mySmartUpload.Upload
    
    '  Select each file
    '  ****************
       For each file In mySmartUpload.Files
       '  Only if the file exist
       '  **********************
          If not file.IsMissing Then
          '  Save the files with his original names in a virtual path of the web server
          '  ****************************************************************************
             file.SaveAs("/johnny/Uploads/" & file.FileName)
             ' sample with a physical path 
             ' file.SaveAs("c:\temp\" & file.FileName)
          SQL = ("insert into pics1 set rspic = '" & (file.filename) & "' where author = '" & session("MM_Username") & "'")
    Conn.Execute(SQL)
    
    MM_editConnection.Execute(SQL)
    		MM_editConnection.Execute("insert into pics1 set rspic = '" & (file.filename) & "' where author = '" & session("variable") & "'")
          '  Display the properties of the current file
          '  ******************************************
             Response.Write("Name = " & file.Name & "<BR>")
             Response.Write("Size = " & file.Size & "<BR>")
             Response.Write("FileName = " & file.FileName & "<BR>")
             Response.Write("FileExt = " & file.FileExt & "<BR>")
             Response.Write("ContentType = " & file.ContentType & "<BR>")
             Response.Write("ContentDisp = " & file.ContentDisp & "<BR>")
             Response.Write("TypeMIME = " & file.TypeMIME & "<BR>")
             Response.Write("SubTypeMIME = " & file.SubTypeMIME & "<BR>")
     		 intCount = intCount + 1
          End If
       Next
    
    '  Display the number of files which could be uploaded
    '  ***************************************************
       Response.Write("<BR>" & mySmartUpload.Files.Count & " files could be uploaded.<BR>")
       
       
    '  Display the number of files uploaded
    '  ************************************
       Response.Write(intCount & " file(s) uploaded.<BR>")%>
    <p class="style3">
      
    <p class="style1">&nbsp;</p>
    <p class="style1">&nbsp;</p>
    </BODY>
    </HTML>

  • #12
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    connection ASP file

    Code:
    <%
    ' FileName="Connection_odbc_conn_dsn.htm"
    ' Type="ADO" 
    ' DesigntimeType="ADO"
    ' HTTP="false"
    ' Catalog=""
    ' Schema=""
    Dim MM_xxx_STRING
    MM_xxx_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("xxx.mdb")
    %>

  • #13
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    ok,
    looks like you've got two execute commands there:

    Conn.Execute(SQL) < remove this one

    MM_editConnection.Execute(SQL) < try using only this

    MM_tis_STRING.Execute(SQL) < if that doesn't work, try this one

  • #14
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by angst
    ok,
    looks like you've got two execute commands there:

    Conn.Execute(SQL) < remove this one

    MM_editConnection.Execute(SQL) < try using only this

    MM_tis_STRING.Execute(SQL) < if that doesn't work, try this one
    thanks I removed Conn.Execute(SQL) there was no need for it!
    now I am back to the start!
    getting: Microsoft VBScript runtime error '800a01a8'

    Object required: ''

    /johnny/upload.asp, line 180

  • #15
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    damn,
    well do the same thing again,
    response.write SQL
    response.end

    and make sure that all your values are making into the insert string.

    -Ken


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •