JS direct access to data-Access

Source: Internet
Author: User

Javascript database connectorjsdbc: Provides JavaScript to effectively connect to the database. Currently, MySQL, SQLite, and access are supported. More databases will be supported later; engineers engaged in Ajax development certainly want to have a component that connects to the database directly through Ajax, which saves many background operation steps, such as eliminating the need to deploy the Java Runtime Environment, without writing a lot of complicated JDBC calls, jsdbc can be well integrated into your application, regardless of the debugging needs or application needs.

/**
* Class description: This script is mainly used to connect to jsdbc for access, so that users can directly use access in Js.
* Event creation:
*/

// Include OCX object
Document. writeln ("<Object ID = 'access' classid = 'clsid: 75bf468e-4ae7-4872-a6fd-1f307d96c65f '");
Document. writeln ("codebase = 'jsdbc _ access. ocx # version = 0,000 '");
Document. writeln ("width = '0' Height = '0'> ");
Document. writeln ("</Object> ");
// Error message
VaR lasterr = "";
// Exec falg
VaR execflag;

/**
* Connecte to access
* Provite: access IP, port, DB name, user, password, charset
*/
Function connectaccess ()
{
Execflag = access. connecte ("D: // personaldocs // oursoft // jsdbc // test_access.mdb", "sa ","");
If (execflag = 1)
Return 1;
Else
{
Lasterr = execflag;
Return 0;
}
}

/**
* Close already open connection
*/
Function closeaccess ()
{
Execflag = access. Close ();
If (execflag = 1)
Return 1;
Else
{
Lasterr = execflag;
Return 0;
}
}

/**
* Exec insert into SQL statement
* @ Param {object} SQL
*/
Function insertaccess (SQL)
{
Execflag = access. insertdata (SQL );
If (execflag = 1)
Return 1;
Else
{
Lasterr = execflag;
Return 0;
}
}

/**
* Exec Database Manager Language
* @ Param {object} SQL
*/
Function execdmlaccess (SQL)
{
Execflag = access.exe cdml (SQL );
If (execflag = 1)
Return 1;
Else
{
Lasterr = execflag;
Return 0;
}
}

/**
* Exec select data from database
* @ Param {object} SQL
* @ Param {object} cnum = number of fields in SQL statement
*/
Function selectaccess (SQL, cnum)
{
VaR rs = access. selectdata (SQL, cnum );
If (Rs. length> 0)
{
VaR array = new array ();
VaR dataset = new array ();
VaR rowsplit = ''; // row interval. Note that this is not a normal '-', but a conversion from 0x06. You can copy it when using it.
VaR fieldspinterval = ''; // field interval. Note that this is not a normal '|', but is converted from 0x05. You can copy it when using it.

Array = Rs. Split (rowsplit );
For (VAR I = 0; I <array. length; I ++)
{
VaR datarow = array [I]. Split (fieldspow );
Dataset [I] = datarow;
}
Return dataset;
}
Else
{
Lasterr = execflag;
Return NULL;
}
}
/**
* Exec Delete SQL statement
* @ Param {object} SQL
*/
Function deleteaccess (SQL)
{
Execflag = access. deletedata (SQL );
If (execflag = 1)
Return 1;
Else
{
Lasterr = execflag;
Return 0;
}
}

/**
* Exec update SQL statement
* @ Param {object} SQL
*/
Function updateaccess (SQL)
{
Execflag = access. updatedata (SQL );
If (execflag = 1)
Return 1;
Else
{
Lasterr = execflag;
Return 0;
}
}

/**
* Exec transcation
* @ Param {object} SQL
*/
Function exectranscationaccess (SQL)
{
Execflag = access.exe ctranscation (SQL );
If (execflag = 1)
Return 1;
Else
{
Lasterr = execflag;
Return 0;
}
}

/**
* Get last error message if exec error from JS
*/
Function getlasterroraccess ()
{
Return lasterr;
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.