<?xml version="1.0" encoding="utf-8"?>
<package>
<?component error="false" debug="false"?>
<comment>
<![CDATA[
Author: Rimifon
LastDate: 10:50 2006-08-19]]>
</comment>
<scriptlet >
<registration class progid="" description="Rivesh Database Operation Component" version="1.2" remotable="true">
<script language="vbscript">
<![CDATA[Function Register()
MsgBox "Welcome to use components, you have successfully registered this component.", 0, "Component Registration Tips"
End Function
Function Unregister()
MsgBox "Thanks for using the component, you have successfully uninstalled this component.", 0, "Component Uninstallation Tips"
End Function]]>
</script>
</registration>
<public>
<property name="Name" disp description="Component name, read-only"><get internalName="ProductName" //</property>
<property name="ConnStr" description="Database Connection String Settings"/>
<method name="CreateAccess" description="CreateBlank Access database, return to the connection string after success">
<parameter name="DbPath" description="The location of the new database, if not specified, use the database location set in ConnStr" />
</method>
<method name="RecordSet" description="Return a database record set object">
<parameter name="ConnectionString" description="Set the connection string for the new record set (use the public connection string if it is empty)" />
</method>
<method name="ParseSql" description="Parse Sql strings, not recommended in vb and vbs">
<parameter name="Sql" description="Sql statement" />
<parameter name="Rule" description="Stands that replace single quotes in Sql statements are default to Chr(12)" />
</method>
<method name="NonQuery" description="Execute a query that does not return the result set">
<parameter name="Sql" description="query statement" />
<parameter name="Rec" description="Recordset object, if empty, temporary recordset object is generated" />
</method>
<method name="Scalar" description="Execute a data that returns a single row and a single field">
<parameter name="Sql" description="query statement" />
<parameter name="Rec" description="Recordset object, if empty, temporary recordset object is generated" />
</method>
<method name="DataSet" description="Execute the query and return the dataset of the specified page number">
<parameter name="Sql" description="query statement" />
<parameter name="Size" description="Set the number of pieces displayed on each page. If it is 0, it will be displayed all" />
<parameter name="Page" description="Set the page number (page)" />
<parameter name="Rec" description="Recordset object, if empty, temporary recordset object is generated" />
</method>
<method name="CompactAccess" description="Compression specifies Access database, return the reason for failure after compression failure">
<parameter name="DbPath" description="Compressed database, if not specified, the database location set in ConnStr is used" />
</method>
</public>
<script language="javascript">
<![CDATA[var Nothing;
var ConnStr = "Driver=Microsoft Excel Driver (*.xls);ReadOnly=0;DBQ=";
function ProductName()
{
return “Ringyun Database Operation Component”;
}
function CreateAccess(DbPath)
{
DbPath = DbPath?("Provider=.4.0;Data Source=" + DbPath):ConnStr;
var Catalog = new ActiveXObject("");
try
{
(DbPath);
();
}
catch(err)
{
DbPath = new Boolean;
= ;
}
Catalog = Nothing;
CollectGarbage();
return DbPath;
}
function RecordSet(ConnectionString)
{
var Rec = new ActiveXObject("");
= ConnectionString?ConnectionString:ConnStr;
= 1;
= 2;
= 3;
return Rec;
}
function ParseSql(Sql, Rule)
{
if(!Rule) Rule="\f";
if((Rule)<0) return Sql;
return (/'/g,"''").replace(new RegExp(Rule,"g"),"'");
}
function NonQuery(Sql, Rec)
{
if(!Rec) Rec = new RecordSet;
= Sql;
();
if(!arguments[1])
{
Dispose(Rec);
}
else
{
if() ();
}
}
function Scalar(Sql, Rec)
{
if(!Rec) Rec = new RecordSet;
= Sql;
();
var Result = ?null:(0).Value;
if() ();
if(!arguments[1]) Dispose(Rec);
return Result;
}
function DataSet(Sql, Size, Page, Rec)
{
var dataArr = new Array;
if(Size instanceof ActiveXObject)
{
Rec = arguments[3] = Size;
Size = 0;
}
if(!Rec) Rec = new RecordSet;
= Sql;
();
Size = parseInt(Size);
if(isNaN(Size) || !Size) Size = ;
if(Size) = Size;
if(!Page || isNaN(Page) || Page<0) Page = 1;
if(Page > ) Page = ;
= Page;
if(Page > 0) = Page;
= ;
= Size;
= ;
var C = 0;
while(! && C++ < Size)
{
var Fields = new Object;
for(var x=0; x<; x++)
{
Fields[x] = Fields[(x).(/\s/g,"_")] = (x).Value;
}
(Fields);
();
}
();
if(!arguments[3]) Dispose(Rec);
return dataArr;
}
function CompactAccess(DbPath)
{
if(!DbPath)
{
DbPath = (/(dbq|data source)=([^;]*)/i);
if(!DbPath) return "No database location specified.";
DbPath = DbPath[2];
}
DbPath = (/\//g,"\\");
var DbName = (("\\")+1);
var BackDb = DbName + () + ".MyDocs";
DbPath = (0, ("\\"));
var DBQ = "Provider=.4.0;Data Source=" + DbPath;
try
{
var Jro = new ActiveXObject("");
var Fso = new ActiveXObject("");
(DBQ+DbName, DBQ+BackDb);
var File = (DbPath+DbName);
();
File = (DbPath+BackDb);
= DbName;
Jro = Fso = Nothing;
CollectGarbage();
}
catch(err)
{
return ;
}
}
function Dispose(Rec)
{
();
Rec = Nothing;
CollectGarbage();
}]]>
</script>
</scriptlet>
</package>