...

View Full Version : Insert Into?



boyjarv
01-20-2006, 05:53 PM
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

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

angst
01-20-2006, 06:31 PM
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

boyjarv
01-20-2006, 06:38 PM
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 = ''

angst
01-20-2006, 06:42 PM
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

boyjarv
01-20-2006, 07:27 PM
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?

NancyJ
01-20-2006, 07:34 PM
I'm assuming that conn really is a connection object?

boyjarv
01-20-2006, 07:44 PM
I don't know what the connection object is?!

angst
01-20-2006, 07:59 PM
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

boyjarv
01-20-2006, 08:19 PM
yes that SHOULD o it but now I get

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/johnny/upload.asp, line 178

Line 178
Conn.Execute(SQL)

is this because I am using a multiple upload?

angst
01-20-2006, 08:27 PM
can u post the whole script, including the connection string? just xxx out any server and login info.

-Ken

boyjarv
01-20-2006, 08:35 PM
upload.asp

<%@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>

boyjarv
01-20-2006, 08:38 PM
connection ASP file


<%
' 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")
%>

angst
01-20-2006, 08:42 PM
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

boyjarv
01-20-2006, 09:01 PM
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

angst
01-20-2006, 09:08 PM
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

boyjarv
01-20-2006, 09:18 PM
insert into pics1 set rspic = 'scaramanga1.jpg' where author = 'admin'

angst
01-20-2006, 09:25 PM
ok, well that looks alright,
by the way, it's a much better idea to use record id in your WHERE statement then a word, but that should work.


-Ken

boyjarv
01-20-2006, 09:28 PM
so... how will it work?!
what do i do?

angst
01-20-2006, 09:31 PM
is it still not working?
your insert looks good to me.
that should work unless i'm missing something. all the values are there.

-Ken

boyjarv
01-20-2006, 09:33 PM
http://www.mutedesigns.co.uk/johnny

register, log in and then click ADD PICTURE!

I have to go now, thanks for all your help so far

angst
01-20-2006, 09:48 PM
looks good to me,
insert into pics1 set rspic = 'qkO7L8a3fbcdQqTDqJ5RzEARzxOf.jpg' where author = 'six'


just remove the response.end,
that should work.

-Ken

ghell
01-21-2006, 01:11 PM
pics1 is actually a table in the database right?..

boyjarv
01-21-2006, 01:39 PM
pics1 is actually a table in the database right?..


yes that is correct a table where the path to the pic goes!


all seems to be working as the SQL gets written out and shows that it uploads the file by the author now i am going to try it and go back and refresh list of PICS1 and i bet it won't show?! in fact I will download my database and i bet it hasn't been inserted??! i'll let you know how it goes

boyjarv
01-21-2006, 01:41 PM
no see, just as i thought...

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/johnny/upload.asp, line 182



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum