Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2004, 12:22 AM
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beg --Object required: '' ? what error did i make?

Help I can't spot my error...


<%
DIM strUsername, strPassword, objConn
DIM mySQL, objRS
Dim strSQL
Dim strID
Dim name

strUsername = Request("admin")
strPassword = Request("pcode")

IF strUsername <> "" THEN
    IF strPassword <> "" THEN
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db\FILE_MGR.mdb")

    mySQL = "Select * FROM Login WHERE uid ='" & strUsername & "' AND pwd ='" & strPassword & "'"
    Set objRS = Server.CreateObject("ADODB.Recordset")

    objRS.Open mySQL, objConn

    Elseif strUserName<>"" AND strPassword ="" then
    %>
    <Script Language = "VBscript"> alert("Please enter your Password!")
    </Script>
    <%
     Elseif strUserName="" AND strPassword <>"" then
    %>
    <Script Language = "VBscript">
    alert("Please enter your Username!")
    </Script>
    <%
    Else
    %>
    <Script Language = "VBscript">
    alert("Please enter your Username and Password!")
    </Script>
    <%
    END IF
END IF
    strID = session("strUsername")

    strSQL = ""
    strUser_Type = ""
    strSQL = "SELECT * FROM Login WHERE uid ='"& strID &"'"

    objRS.Open strSQL, objConn <-this is the error line

    If objRS.EOF Then
    If (RS("User_Type") = "admin") Then
                        Response.Redirect "Admin.asp"
    Else If (RS("User_Type") = "user") Then
                        Response.Redirect "User.asp"
    Else
    %>
    <Script Language = "VBscript">
    alert("Invalid! You need to register!")
    </Script>
    <%
    End If
End If
End If
%>
 
Old April 26th, 2004, 04:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You havenot specified what ERROR you got there. But as per the code, I hope it tells you something related to RECORDSET OPEN(Cannot perform this operation when the recordset is open)--- something like that.

You have not closed you recordset objRs after your first QUERY

Code:
mySQL = "Select * FROM Login WHERE uid ='" & strUsername & "' AND pwd ='" & strPassword & "'"
    Set objRS = Server.CreateObject("ADODB.Recordset")

    objRS.Open mySQL, objConn


I dont really find anything that you do after opening the recordset there. Probably I would say you can remove the blocked lines there.

And again you are trying to open the same as given here.

Code:
objRS.Open strSQL, objConn <-this is the error line
And you will have to relook your code again. It is been written without a proper approach.

What is RS in this code?
Code:
 If (RS("User_Type") = "admin") Then
You ahve note defined it anywhere else. You got to change it to objRS

Feel free to ask if any issues

Cheers!

-Vijay G
 
Old April 26th, 2004, 02:24 PM
Registered User
 
Join Date: Apr 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, I need help on this!
I need to have a drop down list that allow user to choose the category folder to store their uploaded files.

I've have a tbl in database with the following fields :
ID (autoNumber), FolderName (Text), FolderPath (Text).

What must I do to create the dropdown list? I have tried the populated drop down from database but I cant't use the normal request("Folder") to get the selected value due to the fact that I'm using Lewis Molten File uploading (Ver.3) to database and folder. I need to store the FolderName and FolderPath to which the files are uploaded to. And from this drop down list, the files will be stored to its chosen folder which is derived from the drop down.

Conclusion:
My needs:
(1) how to upload binary file to chosen the destination which is the selected value (in this case is the folder name and the corresponding folderpath)from the dropdown list and make the file store in database and chosen folder?


this is my Upload_Files.asp form where user will choose the destination to store the uploaded file from drop down
      <td width="89%" bgcolor="#6699FF">
    <select size="1" name="folder">
    <option>---Please Select---</Option>
    <%
    Dim con
    Dim rs
    Dim sql
    Dim folder

    folder = Request("folder")

    Set con = Server.CreateObject("ADODB.Connection")
    Set rs = Server.CreateObject("ADODB.Recordset")

    con.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("db\FILE_MGR.mdb")

    sql = "SELECT * FROM Folder WHERE FolderName='"& folder &"'"
    rs.Open sql, con

    Do Until rs.EOF
    %>
    <option value="<%=rs("FolderName")%>"><%=rs("FolderName")% ></Option>
    <%
    rs.MoveNext
    Loop
    rs.Close
    Set rs = Nothing
    %>
    </select>
      </td>
this is my Upload_Process,asp, where i have scripts to store binary file to database and folder.
Dim Sql, sql1
Dim fileN

Dim FileID
Dim FileName
Dim Upload

Dim FoldernFileName
Dim Folder
Dim FolderSelect
FolderSelect = Upload.Fields("folder").Value


Set Upload = New clsUpload

' Set the file name to be unique.
FileName = Upload.UniqueName(Folder, FileName)

If Recordset("FolderName")=FolderSelect Then
    sql1 = "SELECT FolderPath FROM Folder WHERE FolderName='"& FolderSelecct &"'"
    Recordset.Open sql1, Connection

    ' Get path to save file to
Folder = Server.MapPath('"& FolderSelect &"') & "\" <--- NOT TOO SURE HERE

FoldernFileName = Folder & FileName

' Save the binary data to the file system
Upload("File1").SaveAs FoldernFileName & Upload("File1").FileName

' Select no records (only schema)
Sql = "SELECT Files WHERE FileID = 0"

RecordSet.Open Sql, Connection, 3, 3

' Add a new record
RecordSet.AddNew

RecordSet.Fields("DateUploaded").Value = Now()
RecordSet.Fields("File").Value = Upload.Fields("fileN").Value
RecordSet.Fields("Category").Value = Upload.Fields("folder").Value
RecordSet.Fields("Description").Value = Upload.Fields("descr").Value
RecordSet.Fields("FileName").Value = Upload.Fields("File1").FileName
RecordSet.Fields("FileSize").Value = Upload.Fields("File1").Length
RecordSet.Fields("ContentType").Value = Upload.Fields("File1").ContentType
RecordSet.Fields("BinaryData").AppendChunk Upload("File1").BLOB & ChrB(0)

' Commit the record to the database
RecordSet.Update

' Move to the last record (updates the FileID)
RecordSet.MoveLast

' Get FileID (populated by auto number data type)
FileID = RecordSet.Fields("FileID").Value

Set Upload = Nothing

    %>
    <Script Language = Javascript>
        alert(Unable to Upload! Invalid Password!);
    </Script>
    <% Upload.Close %>


<P>
    File has been saved in database.
</P>
<P>

<A href="Database_Download.asp?FileID=<%=FileID%>"><% =FileName%></A>
</P>


And my last need, I'm also creating a search page. This search allow user to key in the file name or description and the result shown will be the hyperlinked filename (also allow downloading).

My Question: How do I retrieve the records from database that matches the search input?

Really hope to hear from you asap. I'm getting depressed on the above queries. (CRYING)


 
Old April 28th, 2004, 09:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sorry, I was off for past two days, So I couldn't check my mails. Thats the reason for the delay in replying you.

Quote:
quote:but I cant't use the normal request("Folder") to get the selected value
You haven't gone through the Document in Molten File UPLOAD site. It is well documented there.;)

Dim Upload
Dim folder
Set Upload = New clsUpload

'Replace this line
'folder = Request("folder")
'This is how you got to use to get values of your other FORM Control Values
folder = Upload("folder").Value

Quote:
quote:My needs:
(1) how to upload binary file to chosen the destination which is the selected value (in this case is the folder name and the corresponding folderpath)from the dropdown list and make the file store in database and chosen folder?
I haven't tested the File upload and Database sync together.
Please go through the DOCUMENT there, to understand the functionality and then go for implementation.

Quote:
quote:And my last need, I'm also creating a search page. This search allow user to key in the file name or description and the result shown will be the hyperlinked filename (also allow downloading).
You can use FileSystemObject for this, than going for a Database related search solution, provided you have planned well about the folder structure and setup required permisssion on the folder for the Internet Guest User.

Quote:
quote:My Question: How do I retrieve the records from database that matches the search input?
You can do that using Like operator, provided you store the filenames too in the databse. Else you can search only for the folder, as per the table structure you have posted.
Quote:
quote:I've have a tbl in database with the following fields :
ID (autoNumber), FolderName (Text), FolderPath (Text).
Are these records insync with the Folder structure that you created for uploading?

Quote:
quote:I'm getting depressed on the above queries. (CRYING)
Never got to cry, there is always someone to help us.;)

Hope that Helps.
Cheers!

-Vijay G





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Required Error JeffGirard Access 5 October 2nd, 2009 08:09 AM
Object Required error voyeur Javascript 9 January 25th, 2008 11:50 AM
Object Required Error when using MoveNext idossa Classic ASP Databases 1 July 19th, 2006 10:56 AM
Object required error ?? hman SQL Server ASP 11 June 21st, 2004 10:59 AM
error....Object required: '' sassenach Classic ASP Databases 2 August 4th, 2003 03:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.