You need to Register for free and Login to post a message in the forum.

Forum

Subject: Replace_DesktopHtml Stored Procedure
Prev Next
You are not authorized to post a reply.

Author Messages
sfkb
Nuke Newbie
Nuke Newbie
Posts:3

04 Jul 2007 9:30 AM  

Lee,

I am glad to see that you are responsive to your reader's needs as we had the discussion of creating a tutorial for transferring a live site to localhost  back in December.


I have transferred a live site to localhost  as described in your tutorials and came accross the following issues:

1.  Many of us do not have IIS but simply use the web server built into VWD and VS 2005. Are there any seperate configuration issues related to this web server?

2. I am attempting to run Replace_DesktopHtml in SQL Server 2005 Express using the following command:

Replace_DesktopHtml '/Portals/0/', '/wwwroot/Portals/0/'

  After running the procedure for 15 minutes it does not complete processing.  There are only about 25 rows in the DesktopHtml  table.  Replace_DesktopHtml simply displays an "Executing query..." message in the lower left hand side and if I click on the Messages tab, I see the message

(1 row(s) affected)

If I check the DesktopHtml table I see that none of the the HTML text has been replaced.

Thanks in advance for our help and keep up the great work.

Stefan Pantu
Computer Software Connection, Inc.

leesykes
DNN Creative Staff
Nuke Master III
Nuke Master III
Posts:3351

04 Jul 2007 2:02 PM  
Hi Stefan,

From this post

I see you have found the solution to the first question.

2.  I don't know why that is timing out, it should literally just take a couple of seconds. I'm not sure what to suggest as I haven't come across this problem before. - Perhaps double check the SQL procedure has been created correctly. Check you are creating a query for the correct database. - Check that the query parses before executing. - Perhaps try it all on a fresh DNN test installation and if this works you may be able to work backwards and see what the problem is in the current installation.

Let us know how you get on, thanks,

Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/leesykes

Lee Sykes's Facebook Profile
sfkb
Nuke Newbie
Nuke Newbie
Posts:3

04 Jul 2007 9:28 PM  

If you have any other insights on using ASP.NET Development Web Server instead of IIS, your comments are appreciated.

I ran Replace_DesktopHtml on the live website and it seems to be working ok.  The Replace_DesktopHtml stored proc was created without errors on my local SQL Server Express database.

I'll try to rebuild the local database from backup and rerun Replace_DesktopHtml.  This time the Replace_DesktopHtml stored proc will be restored along with the backup.

Thanks,

Stefan

tjimmus
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:7

31 Jul 2007 7:55 AM  

Dear Lee,

I also have a question about this article and I hope it is ok to ask it here.

First of all I have succesfully ran the query to change the image URLs in the text/html modules. I used the second method (SQL management studio express) and it actually took me some time to find out that I had to include the prefix of our TextHtml table.

After doing this I thought I had gained sufficient expertise to adjust the query for the Announcement module (I have inserted images) but this turned out very bad.

Could you please tell me which aspects of the query to change in order to delete the reference to our localhost installation folder (image URL) in the announcements?

Greetings Tim

jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2357


31 Jul 2007 8:49 AM  
Tim,

Can you post an example of the html code, like a sample img tag, from your announcements module?

Joe Craig
DNN Creative Support
Subscribe to the website
tjimmus
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:7

31 Jul 2007 8:58 AM  

Thanks for your reply. Here is an example, I have just copied the whole tag:

aspecs 8

tjimmus
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:7

31 Jul 2007 9:01 AM  
Oops I'm sorry I should have known it would treat it as HTML. Another try:

img height="200" alt="aspecs 8" hspace="10" width="150" align="right" src="/icopportal/Portals/0/images/aspecs8_as.jpg"
jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2357


31 Jul 2007 9:04 AM  
The important part is:

src="/icopportal/Portals/0/images/aspecs8_as.jpg"

You want to change it to:

src="/Portals/0/images/aspecs8_as.jpg"

If you only have a few announcements, I'd probably suggest that you just go in and edit each of them inside of the announcements module.

If you want to do this with an SQL query, you'll be working in the dbo.announcements table, and with the column that contains the html for the announcements. That column is "Description."

Joe Craig
DNN Creative Support
Subscribe to the website
tjimmus
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:7

31 Jul 2007 9:18 AM  

Thanks again. I actually have (ab)used the announcement module for news, reference projects and publication. All together I think I would have to edit 60 announcements ;).

As I wrote before I tried to edit the query and acoording to your reply, I was actually searching in the right direction. I found the dbo.announcements and the Description column. When I executed the query it actually corrected the image url in the first announcement but over wrote the content of the following announcements with the content of the first.

This is the query I used (I hope pasting this code works):

CREATE Procedure Replace_Description(
    @For as varchar(100),
    @With as varchar(100))
AS
--* REPLACES TEXT IN THE DESCRIPTION MATCHING THE FOR VARIABLE
--* SAMPLE: Replace_Description '/Portals/0/', ''

--* MAIN DECLARATION
DECLARE
    @pointer binary(16),
    @index INT,
    @lenFor INT,
    @lenWith INT,
    @diff int,
    @id INT,
    @count INT

--* STANDARD RUNTIME VARIABLES
SET @lenFor = LEN(@For)
SET @diff = @lenFor - LEN(@With)

--* CREATE THE TEMPORARY TABLE
CREATE TABLE #Temporary
    (
        [id] int,     --MAPS TO YOUR SOURCE TABLE PKID
        [oldtext] text, --ORIGINAL SOURCE TEXT (NOT REQUIRED)
        [oldlength] int,--ORIGINAL SOURCE LENGTH
        [text] text,     --NEW TEXT VALUE
        [length] int,     --NEW LENGTH
        [cLength] int    --CHECKSUM LENGTH
    )

--* LOOP THROUGH THE SOURCE TABLE
--* IDENTIFY ALL RECORDS WHICH MATCH YOUR PATTERN
DECLARE irows CURSOR
    LOCAL FORWARD_ONLY STATIC READ_ONLY FOR
    SELECT moduleid
        FROM prefix_Announcements
        WHERE PATINDEX('%'+@For+'%', Description)>0
OPEN irows

FETCH NEXT FROM irows INTO @id

WHILE (@@FETCH_STATUS = 0)
BEGIN
--* INSERT MATCHING RECORDS INTO THE TEMPORARY TABLE
    INSERT INTO #Temporary(id, oldtext, oldlength, text)
    SELECT
        ModuleID,
        Description,
        datalength(Description),
        Description from prefix_Announcements
    where ModuleID = @id

--* GRAB THE POINTER OF THE OBJECT TO BE USED FOR UPDATETEXT
    SELECT
        @pointer = TEXTPTR(text)
    FROM #Temporary
    WHERE id=@id
--* GET THE FIRST INDEX OF OUR PATTERN
    SELECT
        @index = PATINDEX('%'+@For+'%', text)
    FROM #Temporary
    WHERE id=@id

--* IF WE FOUND ANY ENTRIES, LOOP UNTIL WE REPLACE ALL OF THEM
    IF @index > 0
    BEGIN
        select @count = 0
        WHILE (
            SELECT
                PATINDEX('%'+@For+'%', text)
                FROM #Temporary
            WHERE id=@id
              ) > 0
        BEGIN
--* KEEP A RUNNING TOTAL OF IDENTIFIED ENTRIES FOR LENGTH CHECKSUM
            select @count = @count + 1
            SELECT
            @index = PATINDEX('%'+@For+'%', text)-1
            FROM #Temporary
            WHERE id=@id

--* UPDATE THE TEMPORARY VALUE        
            UPDATETEXT #Temporary.text @pointer @index @lenFor @With
        END
--* UPDATE THE TEMPORARY RECORD, SET LENGTH AND CLENGTH VALUES FOR CHECKSUM
        UPDATE #Temporary set
            length=datalength(text),
            cLength=datalength(oldtext) - @count * @diff 
        WHERE id=@id
    END
    FETCH NEXT FROM irows INTO @id
END

CLOSE irows
DEALLOCATE irows
--* UPDATE THE DATABASE FOR ALL RECORDS IN THE TEMPORARY
--* WHERE THE CHECKSUM LENGTH MATCHED THE RESULT LENGTH
UPDATE target set
    target.Description = t.[text]
FROM
    prefix_Announcements target JOIN #Temporary t
    ON
        target.ModuleId = t.id AND
        t.length = t.cLength

--* DELETE ALL RECORDS FROM TEMPORARY WHICH WERE SUCCESSFUL
DELETE from #Temporary where length=clength

--* RETURN ALL ROWS WHICH FAILED LENGTH COMPARISON
--* THIS SHOULD ALWAYS BE EMPTY
select * from #Temporary

--* DROP THE TEMP TABLE AND EXIT
DROP TABLE #Temporary

jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2357


31 Jul 2007 9:33 AM  
I haven't studied or used this sql procedure, but I think that you need to take the original and make these substitutions:

moduleid --> itemid
desktophtml --> description
htmltext --> announcements

Hopefully you've backed up your database. I'd also suggest that you try this first on a copy of your database before doing it to the live one!

Joe Craig
DNN Creative Support
Subscribe to the website
datamark
DNN Creative Magazine Subscriber

Posts:10

31 Jul 2007 9:34 AM  
Lee, have you worked with MS Acess or similar smaller databases? What do you think of this idea? A person could make an ODBC connection to the DotNetNuke database and then open Access and link to all the tables in the DotNetNuke database. Then, to see the data in the DNN database, one only has to open a local Access database and open a table. (This I have already done) It is conceivable to me, although I have not tried it, to run an Access query to look for those strings and then edit the returned records either manually for smaller datasets or run an update query for the larger ones.

What do you think?

The advantage that appeals to me is that I get to see each text string that is getting changed and would worry less that my SQL query changed a string here or there that it shouldn't have.
tjimmus
DNN Creative Magazine Subscriber
Nuke Newbie
Nuke Newbie
Posts:7

31 Jul 2007 10:16 AM  
Joe thank you very very very much. Changing moduleid to itemid was the hint I was hoping for! Works perfectly now.
jncraig
DNN Creative Staff
Nuke Master II
Nuke Master II
Posts:2357


31 Jul 2007 10:22 AM  
Good. If you look in that announcements database table, you'll see that ModuleID is the same for every entry (assuming that you have only one announcements module in use). That's why it was changing everything!

Joe Craig
DNN Creative Support
Subscribe to the website
leesykes
DNN Creative Staff
Nuke Master III
Nuke Master III
Posts:3351

01 Aug 2007 4:11 AM  
datamark,

I have not tried it. - I would create a test installation of DNN and then try out what you suggest, anything like this always experiment with a test installation first.

Thanks,

Lee Sykes
Site Administrator
Subscribe to the website : DotNetNuke Video Tutorials : The Skinning Toolkit : DotNetNuke Podcasts

Twitter: www.twitter.com/leesykes

Lee Sykes's Facebook Profile
You are not authorized to post a reply.
Forums > Users Lounge > DNN Creative Articles > Replace_DesktopHtml Stored Procedure



ActiveForums 3.7

Latest Forum Posts

Yahoo Answers by cdtguru
Hey, i was wondering if anyone knew of a module that would create a similar system to Yahoo Answers...
(catalook) Itempane changes on product pages ?? by Gaz35
Hi , hi , I don’t know if you can help me , here is the site in question http...
RE: Virtual Pc 2007 help by jeff@zina.com
You need to get the Virtual PC's network set up.  Might check the Virtual PC news group: http://www...
DNNCreative Just Keeps Getting Better by jeff@zina.com
Kudos on issue 39, the article on importing large quantities of data was both timely for me and spot...
RE: Videos by clippy
Hello from France My question is about the videos for beginners, and specially n° 3; I'm working...
skinning trouble by derpir
HelloI have uploaded a skin to my DNN-website, but I want to make som changes. I have made some chan...
RE: Column width in UDT by VickySwift
In case anyone else is looking for the answer to this, I have been able to add the headers back in b...
RE: search not working by jncraig
Did you either reindex the site to turn on the scheduled task to do it?
RE: Template Issue by jncraig
No, you need to install your custom modules before you use the template.
RE: error message in registration page by jncraig
I'm not sure that you can avoid them, short of rewriting the module.You might want to investigate Dy...
Template Issue by Bobbyjosephg
Hi,   Today I have come up with a problem with templates.I was successful in exporting a template an...
RE: search not working by sanju_k1421
I checked     host==>admin search  page   that is set both limits min //max  page     still i m n...
RE: error message in registration page by coder247
but how do I avoid the error messages provided by default in dnn?
RE: Style sheet does nothing by andorz
Oh. I was told to do that in my thread at the dotnetnuke.com forum. http://www.dotnetnuke.com/Commun...
RE: Videos by clippy
Thank you to answer so quickly. It's really kind from you. I appreciate
RE: Simple subscribe newsletter module by jncraig
I seem to recall that DataSprings has an "Opt In" module. I haven't used it, though.
RE: Videos by jncraig
No, you can view them in any order.
RE: Skim Question by tlsadler
Wow! Went to Snowcovered and the 50% off Promo more then paid for itself. I actually wound up buying...
Videos by clippy
Hello from FranceJust a little questionIs there any order to respect to look the videos ("issues"). ...
RE: Skim Question by tlsadler
Thank you very much. I've followed many of your posts and will check it out. I had thought about get...
DotNetNuke Modules
RSS Feeds