Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 September 15th, 2006, 02:50 AM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with copyRecord method of Record object

Hi everybody!

I hope you guys can help me. For those of you who have the book "Beginning Active Server Pages 3.0", I am trying the example on pages 619-621. I followed all the instructions verbatim on how to create the TestFolder and make it an app using the IIS snap-in of my MMC. Here is a link to a screen capture of my server structure: http://www/tarasdemos.com/images/MyIISTree.gif.

Now here's the code copied verbatim from the book except it has my server name "tk" as the server name.

Code:
<% Option Explicit %>

<html>
<head>
<title>Retrieving Semi-Structured Data</title>
</head>
<body>
<%
  If Request.Form("Task") = "" Then %>
    <form name="MovieInfo" action="RecordMove.asp" method="post">
    What do you wanna do? <br><br>
    <input type="radio" name="Task" value="Copy" checked>
    Copy MyText.txt to a new file called MyText2.txt</input><br>
    <input type="radio" name="Task" value="Move">
    Move MyText.txt to a new file called MyText2.txt</input><br>
      <input type="radio" name="Task" value="Delete">
    Delete MyText.txt from the BegASP folder</input><br>
    <input type="submit" value="Go">
    </form><%
  Else
    Dim objRecord
    Set objRecord = Server.CreateObject("ADODB.Record")
    objRecord.Open "MyText.txt", "url=http://tk/BegASP/"
    If Request.Form("Task") = "Copy" Then
    objRecord.CopyRecord "", "http://tk/TestFolder/MyText2.txt", , ,adCopyOverWrite
    Response.Write "MyText.txt file copied to a new file called MyText2.txt"
    ElseIf Request.Form("Task") = "Move" Then
    objRecord.MoveRecord "", "http://tk/TestFolder/MyText2.txt", , , adMoveOverWrite
        Response.Write "MyText.txt file moved to a new file called MyText2.txt"
    ElseIf Request.Form("Task") = "Delete" Then
    objRecord.DeleteRecord
    Response.Write "MyText.txt has been deleted"
    End If
    objRecord.Close
    Set objRecord = Nothing
  End If
%>
</body>
</html>
However, when I run it, and click the first radio button followed by Submit, I get an error msg saying "An exception of type 'Runtime Error' was not handled. Would you like to debug the application?" Then when I debug it, it highlights the line that says:

Code:
objRecord.CopyRecord "", "http://tk/TestFolder/MyText2.txt", , ,adCopyOverWrite
(which I have bolded above). No further info is given, other than in my browser window, it points to that same line and says "Server cannot complete the operation". I hope I am making sense here.

Your help will be greatly appreciated.

Syster Tara
 
Old September 15th, 2006, 07:34 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The CopyRecord method takes 5 parameters as so:

CopyRecord([src], [dest], [username], [psword], [option], [async])

I think your problem is that you have defined a destination, but have not defined a source so try:

objRecord.CopyRecord("http://tk/folder/MyText1.txt", "http://tk/TestFolder/MyText2.txt", , ,adCopyOverWrite)

also, you may want to omit the HTTP and try using relative paths for example Server.MapPath("./folder/MyText1.txt") and Server.MapPath("./TestFolder/MyText2.txt") (for those specific examples to work, I assume that the script calling the method is in the root directory of the directory that contains both folder and testfolder.)

hth.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.

Unless, of course, you want to hire me to do work for you.
 
Old September 17th, 2006, 01:42 AM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

DParsons,

I tried everything you suggested, plus a lot of other things. They are:

1. Used the 5 parameters where you told me to put them (src, dest, username, pwd, option)

2. Specified the source

3. Took out the http

4. Tried relative paths

5. Tried the Server.MapPath method

6. Replaced my server name with "localhost"

7. Pored and pored over the example in the book "Beginning Active Server Pages 3.0" until I'm absolutely blue in the face.


I have done all those things and still nothing works. I get the same error that says "Cannot complete the operation". Could the book be wrong? I noticed that it was written in 1999. Do you reckon that the code for this example may no longer be supported by my browsers (IE 6 and Netscape 7)? I really hope you or someone else here can still help me.

Syster Tara
 
Old September 17th, 2006, 12:43 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

First, remember that ASP is a SERVER SIDE language, it has little to do with your browser and everything to do with your server.

Most probably what you are seeing here is a permissions issue between the directories because the directory you are copying to you will need Write rights I would look into that. (I doubt the book is wrong)

--Stole this from a moderator

I will only tell you how to do it, not do it for you.

Unless, of course, you want to hire me to do work for you.
 
Old September 17th, 2006, 09:21 PM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I enabled write permissions for the MyText.txt file, the TestFolder folder, and the BegASP folder. Nothing works. Is this an example I have no business doing? Should I just skip over it and move on? Because it's very obvious that there's nothing anyone can do to make it work.

 
Old September 17th, 2006, 09:32 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Grant full permissions to both folders and see what happens.

Also, on a more personal level, when working with a problem and nothing seems to work you shouldn't just "give up" because, in the real world of programming, you can't just give up on something because your having a problem.

As a programmer, there will come times where something just seems impossible (we have all been there) but eventually you will solve the problem and you feel a lot better about being a programmer =]

--Stole this from a moderator

I will only tell you how to do it, not do it for you.

Unless, of course, you want to hire me to do work for you.
 
Old September 19th, 2006, 09:53 PM
Authorized User
 
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just did that and it still does not work. Is it because I'm not supposed to be doing this? I bet if I were someone else, it would work. Try it on your computer and tell me how beautifully it works.

 
Old September 19th, 2006, 10:55 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I am at a loss then, the last thing id do is jump on the MSDN and see if there is a KB article on this.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Method reffering to an object beccali JSP Basics 1 March 23rd, 2007 07:24 AM
Object Rexx - Method Not Found ALFisher Other Programming Languages 0 September 7th, 2006 08:55 PM
Referencing the object that invoked a method benr Classic ASP Professional 0 March 12th, 2006 01:55 PM
ADO Stream/CopyRecord failure ken1 BOOK: Beginning ASP 3.0 4 July 18th, 2004 12:31 PM





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