Upgrading SimpleBlog version 1.0 to version 2.0
(No guarantees, if this doesn't work, then this doesn't work and don't bother me about it! )1. make sure you have your version 1 database(your old blog) in DB folder, renamed to simpleblog_OLD.mdb. Now you should have simpleblog.mdb(new) and simpleblog_OLD.mdb in your db folder.
2. click this link and do not interrupt process:
upgrade simpleblog v1.0 >> v2.0
<%
if request.QueryString("cmd") = "do-it" Then
response.Write("
upgrading simpleblog to version 2.0, do not interrupt process!")
response.Flush()
' move records from old to new, tables:T_WEBLOGS and T_COMMENTS */
strConnOLD = "DRIVER={Microsoft Access Driver (*.mdb)}; Dbq=" & Server.MapPath("../db/SimpleBlog_OLD.mdb") &";"
strSQL = "SELECT * FROM T_WEBLOG"
Set RsOLD = Server.CreateObject("ADODB.Recordset")
RsOLD.ActiveConnection = strConnOLD
RsOLD.Source = strSQL
RsOLD.CursorType = 0
RsOLD.CursorLocation = 2
RsOLD.LockType = 1
RsOLD.Open()
RsOLD.MoveFirst
while Not RsOLD.EOF
int_OLD_ID = RsOLD("id")
strHeader = RsOLD("b_headline")
strHeader = replace(strHeader,"'","''")
strContent = RsOLD("b_content")
strContent = replace(strContent,"'","''")
strDate = dateToInt(RsOLD("b_date"))
strTime = RsOLD("b_time")
intMonth = RsOLD("b_month")
intYear = RsOLD("b_year")
intPublished= RsOLD("b_published")
strSQLupgrade = "INSERT INTO T_WEBLOG (b_headline, b_content, b_date, b_time,b_month,b_year,b_published) values ('"&strHeader&"','"&strContent&"',"&strDate&",'"&strTime&"',"&intMonth&","&intYear&","&intPublished&")"
Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open strConn
MyConn.Execute(strSQLupgrade)
MyConn.Close
Set MyConn = Nothing
' need to get ID of new record, select all relative comments and move them to new database */
Set RsTMP2 = Server.CreateObject("ADODB.Recordset")
RsTMP2.ActiveConnection = strConn
RsTMP2.Source = "select MAX(id) from T_WEBLOG"
RsTMP2.CursorType = 0
RsTMP2.CursorLocation = 2
RsTMP2.LockType = 1
RsTMP2.Open()
tmpID = RsTMP2(0)
RsTMP2.close()
set RsTMP2 = nothing
' now move the comments */
strSQL = "SELECT * FROM T_COMMENTS WHERE c_bID_fk = " & int_OLD_ID
Set RsCOMMENTS = Server.CreateObject("ADODB.Recordset")
RsCOMMENTS.ActiveConnection = strConnOLD
RsCOMMENTS.Source = strSQL
RsCOMMENTS.CursorType = 0
RsCOMMENTS.CursorLocation = 2
RsCOMMENTS.LockType = 1
RsCOMMENTS.Open()
if not RsCOMMENTS.EOF Then
RsCOMMENTS.MoveFirst
while Not RsCOMMENTS.EOF
bID = tmpID
strName = RsCOMMENTS("c_name")
strEmail = RsCOMMENTS("c_email")
strUrl = RsCOMMENTS("c_url")
strComment = RsCOMMENTS("c_content")
strComment = replace(strComment,"'","''")
strComment = replace(strComment,vbCrLf,"
")
strTime = RsCOMMENTS("c_time")
str_userIP = RsCOMMENTS("ip")
strSQLupgrade = "INSERT INTO T_COMMENTS(c_content, c_name, c_email, c_url, c_time, c_bID_fk,ip) VALUES ('" & strComment & "','" & strName & "','" & strEmail & "','" & strUrl & "','" & strTime & "'," & bID & ",'"&str_userIP&"')"
Set MyConn = Server.CreateObject("ADODB.Connection")
MyConn.Open strConn
MyConn.Execute(strSQLupgrade)
MyConn.Close
Set MyConn = Nothing
response.Flush()
RsCOMMENTS.MoveNext
Wend
end if
RsOLD.MoveNext
Wend
RsOLD.close()
set RsOLD = nothing
response.Flush()
response.Write("
process done")
end if
%>