ASP Code
  Home arrow ASP Code arrow DB Tables Backup using ASP, OO4O and Oracl...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP CODE

DB Tables Backup using ASP, OO4O and Oracle's Export Utility by Jenny Corpus
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2001-09-05

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    DB Tables Backup using ASP, OO4O and Oracle's Export Utility
    by Jenny Corpus

    This is a simple ASP program that allows the user to create
    a backup copy of a DB user's tables. It uses Oracle Objects for OLE (OO4O)
    for database access to Oracle and for the backup function, Oracle's
    Export Utility program is used. 
    This code assumes that the web server has the following installations:
    1.Oracle Net8
    2.Oracle Object for OLE

    Here is the code:

    '************** Start**********************'
    File: Export.asp
    <%@ Language=VBScript %>
    <%Option Explicit%>
    <%

    dim OraDatabase 'Oracle Database object
    dim OraDynaset 'Oracle Dynaset object

    dim sExpPath 'physical path of Export program in the web server
    dim sExpFileNm 'physical path and file name of the Export file to be created
    'physical path must be existing in the web server


    sExpPath = "d:\oracle\ora817\bin\exp.exe" 'set the location of the export program
    sExpFileNm = "d:\Test\EXPDAT.DMP" 'set the name of the Export file to be created

    'Main Procedure
    Sub Main()

    if Request.Form("hidSubmit")="1" then 'Check if the form is submitted
    Call DoExport() 'Execute Export program
    end if

    Call Header() 'Write the Header
    Call Body() 'Write the Body
    Call Footer() 'Write the Footer

    End Sub

    'Export Procedure
    Sub DoExport()
    Dim nCount 'number of rows
    Dim nCtr 'counter for the loop
    Dim sTabList 'list of selected Tables to be exported
    Dim sTabNm 'selected Table Name

    nCount = int(Request.Form("hidCount")) 'Get the total number of rows

    'Check each checkbox of it is selected
    For nCtr=1 to nCount
    if Request.Form("chkExport" & nCtr) = "on" then 'Check if checkbox is checked
    sTabNm = Request.Form("hidTabNm" & nCtr) 'Get the selected Table Name
    sTabList = sTabList & "," & sTabNm 'Place selected name in the list of tables to be exported
    end if
    next

    sTabNm = Right(sTabList, Len(sTabList) - 1) 'Remove the comma at the start of the list

    Call ExportTables(sTabList) 'Export the tables

    End Sub

    '********************************
    'Execute the Export program
    Sub ExportTables(sTabNm)
    dim wsh 'WScript object
    dim sCommand 'Export command
    dim sConnection 'DB connection string

    'Make the DB Connection string
    sConnection = AppDic("UserName") & "/" & AppDic("Password") & "@" & AppDic("DBName")

    'Create the Export command
    sCommand = sExpPath & " " & sConnection & " tables=" & sTabNm & " File=" & sExpFileNm

    'Create the WScript Object
    set wsh = server.createobject("WScript.Shell")

    'Run the Export command
    wsh.run sCommand 

    End Sub
    '*********************************

    'Writes the HTML Header
    Sub Header()
    %>
    <HTML>
    <HEAD>
    <meta HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
    </HEAD>
    <SCRIPT language=javascript>

    //Checks or Unchecks all the checkboxes
    function CheckAll()
    {
    var nCount;
    var sChkName;
    var nCheck

    nCount = document.forms[0].hidCount.value;
    if (document.forms[0].btnCheck.value=="Check")
    {
    nCheck=1;
    document.forms[0].btnCheck.value="UnCheck";
    }
    else
    {
    nCheck=2;
    document.forms[0].btnCheck.value="Check";
    };

    for (var i=1; i <= nCount; i++)
    {
    sChkName="chkExport" + i;
    if (nCheck==1)
    {
    document.forms[0].item(sChkName).checked=true;
    }
    else
    {
    document.forms[0].item(sChkName).checked=false;
    };
    };
    };

    //submit form
    function Export()
    {
    document.forms[0].hidSubmit.value=1;
    document.forms[0].method='POST';
    document.forms[0].submit();
    };
    </SCRIPT>
    <BODY>
    <%
    End Sub

    'Retrieve tables of user from DB
    Function GetResults
    Dim sqlStatement 

    ' Get the reference to the OraDatabase object from the pool
    set OraDatabase = OraSession.getDatabaseFromPool(10)

    if Oradatabase is nothing then 'Check if connection is successful
    GetResults=-1
    Exit Function
    else
    'Make the select statement
    sqlStatement = "SELECT table_name, tablespace_name FROM user_tables " 

    'Execute the select statement, store it in the Dynaset
    set OraDynaset = OraDatabase.CreateDynaset(sqlStatement, cint(0))
    if OraDynaset.RecordCount < 1 then 'Check if there are records retrieved
    GetResults=-2
    Exit Function
    else
    GetResults=1
    End if
    end if

    End Function

    'Displays error message on the HTML
    Sub DisplayError(nError)
    Dim strWrite

    Select Case nError
    Case -1
    strWrite="No Connection."
    Case -2
    strWrite="No records retrieved"
    end select

    Response.Write strWrite

    End Sub

    'Displays the retrieved rows in an HTML table
    Sub DisplayTable()
    dim strWrite 'string to write
    dim nCount 'Number of rows retrieved

    %>
    <FORM Method=POST >
    <TABLE border=1>
    <TR>
    <TD><INPUT type='button' name="btnCheck" value="Check" onclick="Javascript:CheckAll()"></TD>
    <TD nowrap> Table Name </TD>
    <TD nowrap> Tablespace Name </TD>
    </TR>
    <%
    nCount = 0
    Do Until OraDynaset.EOF
    nCount = nCount + 1
    strwrite = "<TR>" 
    strwrite = strwrite & "<TD nowrap><INPUT type='hidden' name='hidTabNm" & nCount &"' value=" & OraDynaset.Fields("table_name") & ">" 
    strwrite = strwrite & "<INPUT type='checkbox' name='chkExport" & nCount & "' ></TD>"
    strwrite = strwrite & "<TD nowrap>" & OraDynaset.Fields("table_name") & "</TD>"
    strwrite = strwrite & "<TD nowrap>" & OraDynaset.Fields("tablespace_name") & "</TD>"
    strwrite = strwrite & "</TR>" & chr(13) & chr(10)
    Response.Write strWrite

    OraDynaset.MoveNext
    Loop

    %>
    </TABLE>
    <BR>
    <INPUT type='button' name='btnExport' value="Export" onclick="JavaScript:Export()">
    <INPUT type='hidden' name='hidSubmit' value=0>
    <INPUT type='hidden' name='hidCount' value=<%=nCount%> >
    </FORM>

    <%

    End Sub


    'Displays the Body of the HTML
    Sub Body()
    Dim nRet 'Return value from GetResults(); 1=OK, -1 or -2=ERROR

    'Get the rows from DB 
    nRet=GetResults()
    If nRet <> 1 then 'Check if there is an error
    Call DisplayError(nRet)
    else
    Call DisplayTable
    end if

    End Sub

    'Writes the Footer of the HTML
    Sub Footer()

    'Set the Oracle objects to nothing
    Set OraDatabase=Nothing
    Set OraDynaset=Nothing

    %>
    </BODY>
    </HTML>
    <%
    End sub


    '****START of server-side procedures****
    Call Main()

    %>
    '************** End********************'


    '************** Start**********************'
    'File: Global.asa

    <OBJECT RUNAT="Server" SCOPE="Application" ID="AppDic" PROGID="Scripting.Dictionary"></OBJECT>
    <OBJECT RUNAT=Server SCOPE=Application ID=OraSession PROGID="OracleInProcServer.XOraSession"></OBJECT>
    <SCRIPT LANGUAGE=VBScript RUNAT=Server> 

    Sub Application_OnStart
    AppDic.Add "DBName","orcl" 'Registered service name in the SQL Net
    AppDic.Add "UserName","scott" 'User name
    AppDic.Add "Password","tiger" 'Password

    OraSession.CreateDatabasePool 20, 100, 600, AppDic("DBName"), AppDic("UserName") & "/" & AppDic("Password"), 0


    End Sub

    Sub Application_OnEnd

    'Destroys global pool of connections.
    OraSession.DestroyDatabasePool 

    End Sub

    </SCRIPT>


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP Code Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    Check out the new Jazz space on developerWorks

    <a href="http://zeus.developershed.com/shonuff.php?blackbird=3853&zoneid=442&source=&dest=http%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fspaces%2Fjazz%3FS_TACT%3D105AGY31%26S_CMP%3DDEVSHED&ismap="><img src="http://images.devshed.com/corp/img/news/jazz01.gif" alt="developerWorks Jazz space" align="left"></a>You've heard the buzz about Jazz... want to know more about it from a developer's perspective? Check out the Jazz space on developerWorks. This space is an up-to-date resource for developers, including technical information about Jazz and products built on Jazz, like Rational Team Concert Express. The Jazz space includes content from a wide variety of sources, including links, feeds, and comments from experts.
    FREE! Go There Now!


    NEW! IBM – Taking Web 2.0 to Work

    David Barnes, Lead Evangelist for IBM Emerging Internet Technologies will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! Download IBM Data Studio V1.1

    Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms.
    FREE! Go There Now!


    NEW! Evaluate WebSphere Extended Deployment Compute Grid V6.1

    Visit IBM developerWorks to download a free trial version of WebSphere Extended Deployment Compute Grid, which lets you schedule, execute, and monitor batch jobs. Because online transaction processing and batch jobs execute simultaneously on the same server resources, you can avoid costly duplication of resources. Compute Grid supports job types of Java transactional batch, compute-intensive and a new type called "native execution", which enables non-Java workloads to run on distributed end points.
    FREE! Go There Now!


    NEW! Info 2.0: Harnessing the power of Web 2.0 and Enterprise Mashups

    Listen to this webcast to get an overview of Info 2.0 and a technical demo of how to quickly build an enterprise mashup. IBM's Info 2.0 technology leverages emerging Web 2.0 technologies such as mashups, feeds, AJAX, and JSON in order to simplify assembly of information using feeds and services. Come learn about the technical elements of Info 2.0 including the Feed Generation framework, Mashup Engine, and mashup assembly components. Learn how to pull information from databases, departmental information, and the Web to create mashups critical to your company’s success. We will also discuss best practices to help you get started.
    FREE! Go There Now!


    NEW! Innovate don't duplicate! Asset reuse strategies for success

    Asset Reuse is a key strategy for companies looking to create innovative solutions to solve complex software development problems. Searching for, identifying, updating, using and deploying software assets can be a difficult challenge. Listen to this webcast, to learn about strategies and tools that you can leverage for a successful project, including Rational Asset Manager, Rational Software Architect and WebSphere Service Registry and Repository.
    FREE! Go There Now!


    NEW! Run your first CICS application on a PC using TXSeries for Windows

    Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1.
    FREE! Go There Now!


    NEW! Successful Change and Release Management for .NET

    Join this webcast to discover the key requirements for successful change and release management. Learn how to extend your .NET environment to improve productivity and collaboration, and address core problems afflicting team development. In this webcast, we’ll review typical challenges faced by customers and how to resolve them with the IBM Rational Change and Release Management solution, including Rational ClearCase, Rational ClearQuest and Rational Build Forge. Replay is available for 9 months.
    FREE! Go There Now!


    NEW! Trial download: IBM Informix Dynamic Server Express Edition V11.0

    Informix Dynamic Server (IDS) Express Edition offers outstanding online transaction processing (OLTP) database performance, while helping to simplify and automate many of the tasks associated with deploying databases for small business applications. IDS 11 further extends the ease of management and applications integration with the Admin API and Scheduler, high availability with Continuous Log Restore for backup server recovery in case of a primary server failure, and column level encryption to protect personal and company private data.
    FREE! Go There Now!


    NEW! Webcast: Striking the right balance between manual and automated testing

    Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP CODE ARTICLES

    - ASP Forms
    - ASP: The Beginning
    - Getting Remote Files With ASP Continued
    - Inbox and Outbox Manipulation in ASP
    - Relational DropDownList Using VB.NET
    - Ad Tracking URL Hits
    - Use ViewState to display one record per page...
    - Send Email using ASP.NET formatted in HTML
    - ASP File Explorer
    - ASP/XML Interview questions by Srivatsan Sri...
    - Various methods of setting Date values to a ...
    - Conditional DataGrid Item and using checkbox...
    - Fill .NET Listbox with SQL DataReader
    - Filling Dropdown box using Code-Behinds in C#
    - FLAMES code sample written in .NET What is F...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek