Advertisement
3_2004-2005 Windows API Call/ Explanation #141458

Basic Windows API Functions. A WHoLE BUNCH!

The purpose of this is to educate people about the wounderful world off A.P.I.. This has over 100 API stuff. In the screenshot there is only like 10. But there are the codes for over 100 stuff in this baby!

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
Upload
<P><FONT face=Verdana><b>Backup data from the Remote Server using the power of 
 ASP</b></FONT><b>&nbsp;<font face=Verdana><b>and ADO </b></font></b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><br>
 <font color="#009933"> <font color="#006699" size="1"><b><br>
 <font color="#666666"> Requiress : IIS 5 , ADO 2.5 and above</font></b></font></font></font></P>
<hr size=0>
<table width="633" border="0" cellspacing="0" cellpadding="0">
 <tr> 
  <td valign="top"> 
   <p> <font face="Verdana, Arial, Helvetica, sans-serif" size="2">So. Your 
    application is up and running smoothly until one day when Murpy's Law 
    catches up. A measure of robustness of a software is not only how well 
    it runs but also how well it is going to recover from unforeseen circumstances 
    like a server crash etc. In the end it is going to depend on one thing: 
    backups.The normal way would be to maintain a copy(or copies) of databases, 
    there are even software available that can do this job. Most probably 
    you are going to store a copy of the database on the server by ftping 
    it to your local machine(in case of MS-Access and like, not MS-SQL Server, 
    Oracle mind you). The database size is also going to be around so much 
    MBs. Dragging such amount of data over the network through unreliable 
    dial-up connections like those available here in India (for example) can 
    be a dreadful chore and also lead to hair loss :-).<br>
    </font></p>
   <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Here is a 
    much faster way of accomplishing it. To give you a comparison we measured 
    the time to store an 4MB (approx.) MS-Access 2000 DB to our local machine 
    from a web server. Time: 6 mins at 21000 bps. The same thing through FTP 
    took around 30 mins. But here we are only storing the tables, not the 
    other database objects. Still that is a lot of time difference.<br>
    <br>
    The sample just gives you the basic working of the technique and there 
    is lot of room for improvement from the side of the user. This article 
    assumes </font><font face="Verdana, Arial, Helvetica, sans-serif" size="2">that 
    the user is comfortable with ADO and ASP. <a href="http://aspalliance.com/anoj/down.zip">Click 
    here</a> to download the sample application .</font></p>
   <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">The Application 
    is divided into two parts , one ASP page which will serve the requested 
    data from the server and the other is the client side application in VB 
    which sends request to the server Application ( using ADO ) for the data 
    of a particular table and after receiving it saves the data to a file 
    at the client end. This datafile can be later manipulated as per user's 
    need.<br>
    <br>
    <b>Backup.asp</b> can process two different inputs. (i) ' option=table 
    ' in this case it will return the Table Schema as recordset. (ii) The 
    second input is the table name eg. 'option=employees' in this case the 
    recordset will be opened using the input table name passed and then returned. 
    <br>
    At the end ' <b>rs.save response </b>' saves the recordset to the response 
    object. Pls note here that to save a recordset in response stream you 
    need IIS 5.0 or above.<br>
    <br>
    Clicking the command button starts the process of download at the client 
    end. At first <font face="Verdana, Arial, Helvetica, sans-serif" size="2">the 
    </font>table list is retrieved by sending request <b><br>
    rs.Open "http://yoursite.com/backup/backup.asp?option=tables"<font face="Verdana, Arial, Helvetica, sans-serif" size="2"><br>
    </font></b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">and 
    list box is filled with table names <b>Me.List1.AddItem rs("table_name") 
    </b> </font></font></p>
   <blockquote> 
    <p> <font color="blue" face="Verdana, Arial, Helvetica, sans-serif" size="2">For</font><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
     i = 0 To Me.List1.ListCount - 1<br>
     Me.Label1 = "Processing Table : " &amp; Me.List1.List(i)<br>
     rs.Open "http://yoursite.com/backup/backup.asp?option=" &amp; Me.List1.List(i)<br>
     <font color="#006600">' pass the Table name to retrieve data</font><br>
     Me.Label1 = "Downloaded data of Table : " &amp; Me.List1.List(i)<br>
     rs.Save app.path &amp; &quot;\&quot; &amp; Me.List1.List(i) <font color="#006600">' 
     save the table locally as file</font><br>
     rs.Close <font color="#006600">' records can also be saved in a local 
     database</font><br>
     <font color=blue>Next</font></font> </p>
   </blockquote>
   <p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Finally a 
    recordset is opened for each table in the Listbox by sending the request 
    to the <b>backup.asp </b>with table name and then saved to a local disk 
    file using<b> rs.Save Me.List1.List(i) </b>method.</font></p>
  </td>
 </tr>
</table>
<P><b> </b><FONT face=Verdana 
size=2><STRONG>Backup.asp</STRONG></FONT></P>
<table width="453" border="0" cellspacing="0" cellpadding="0" bgcolor="#cccccc">
 <tr> 
  <td valign="top"> 
   <pre><font 
style="BACKGROUND-COLOR: yellow" color=green><br>&lt;%</font>
   
 <FONT color=blue>dim</FONT> con,rs,query
 query=request("option")  <br><br> <FONT color=blue>set</FONT> con=Server.Createobject("ADODB.Connection") 
   con.open "give your connectionstring here"  
 <FONT color=blue>set</FONT> rs=Server.CreateObject("ADODB.Recordset")
 
 <FONT color=blue>if</FONT> query="tables" <FONT color=blue>then </FONT> <font color="#006600">' if table list is requested return the table list</font>
   set rs=con.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "Table")) 
 <FONT color=blue>else</FONT>   
          <font color="#006600">' else return the requested records </font>
   rs.open "select * from [" &amp; query &amp; "]",con
 <FONT color=blue>end if</FONT>
  
 rs.save response   <font color="#006600">' save the recordset in response object </font>
 rs.close       <font color="#006600">' and it will be retrieved by ADO at the client side</font>
 set rs=nothing
 con.close
 <FONT color=blue>set </font>con=<FONT color=blue>nothing<br><br><font 
style="BACKGROUND-COLOR: yellow" color=green>%&gt;<br></font></font></pre>
  </td>
 </tr>
</table>
<P><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Below is the code 
 for the sample VB application which will retrive the data from the above ASP 
 <br>
 and save it locally as data files. <br>
 <b><br>
 Backup.frm </b></font></P>
<table width="683" border="0" cellspacing="0" cellpadding="0" bgcolor="#cccccc">
 <tr> 
  <td valign="top"> 
   <pre><font color="#006600">' Declare the Recordset object in general section</font> 
<font color=blue>dim</font> rs As ADODB.Recordset <br><br><font color=blue>Private</font> <font color=blue>Sub</font> Command1_Click()<br>  <br>  <font color=  blue><font color=blue><font color=blue>set</font></font></font> rs = New ADODB.Recordset<br>  rs.Open "http://yoursite.com/backup/backup.asp?option=tables" 
      <font color="#006600">' change the above URL to your URL</font><br><br>  Me.Label1 = "Table list opened"  <br>  <font color=blue>While</font> <font color=blue>Not</font> rs.EOF          <br>     Me.List1.AddItem rs("table_name") <font color="#006600">' Add the table list to ListBox</font><br>     rs.MoveNext<br>  <font color=blue>Wend</font>  <br><br>  rs.Close<br><br>  Me.Label1 = "Processing tables .."<br>  <font color=blue>Dim</font> i As Integer<br>  <font color=blue>For</font> i = 0 To Me.List1.ListCount - 1<br>    Me.Label1 = "Processing Table : " &amp; Me.List1.List(i)<br>    rs.Open "http://yoursite.com/backup/backup.asp?option=" &amp; Me.List1.List(i)<br>                 <font color="#006600">' pass the Table name to retrieve data</font><br>    Me.Label1 = "Downloaded data of Table : " &amp; Me.List1.List(i)<br>    rs.Save app.path &amp; &quot;/&quot; &amp; Me.List1.List(i) <font color="#006600">' save the table locally as file</font><br>    rs.Close         <font color="#006600">' records can also be saved in a local database</font><br>  <font color=blue>Next</font>  <br><font color=blue>End Sub<br></font></pre>
  </td>
 </tr>
</table>
<P><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <br>
 </font></P>
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine