JS Operation Access Database
Copy Code code as follows:
<script language= "JavaScript" >
<!--
var filePath = location.href.substring (0, Location.href.indexOf ("instance 197. Connect Access database. html")); Locate the absolute path where the file is located based on the current paging file
var path = FilePath + "197.mdb";
Path = path.substring (8);
var objdbconn = new ActiveXObject ("ADODB. Connection ");
var strdsn = "Driver={microsoft Access driver (*.mdb)};d bq=" + path;
Objdbconn.open (STRDSN);
document.write ("Connect Access database successfully!<br>");
Objdbconn.close ();
-->
</SCRIPT>
Connecting to SQL Server databases
Copy Code code as follows:
<script language= "JavaScript" >
<!--
var objdbconn = new ActiveXObject ("ADODB. Connection ");
var strdsn = "Driver={sql Server}"; server= (local); Uid=sa; Pwd=111111;database=hljdatabase ";
Objdbconn.open (STRDSN);
document.write ("Database connection successful <br>");
Objdbconn.close ();
-->
</SCRIPT>
Querying database instances
Copy Code code as follows:
<script language= "JavaScript" >
<!--
var objdbconn = new ActiveXObject ("ADODB. Connection ");
var strdsn = "Driver={sql Server}"; server= (local); Uid=sa; Pwd=111111;database=hljdatabase "; Need to modify your server address, username, password
Objdbconn.open (STRDSN);
var objRS = Objdbconn.execute ("Select * FROM table where association = 0"); Enter a local table
var fdcount = objRS. fields.count-1;
if (!objrs. EOF) {
document.write ("<table border=1><tr>");
for (Var i=0 i <= fdcount; i++)
document.write ("<td><b>" + objRS). Fields (i). Name + "</b></td>");
document.write ("</tr>");
while (!objrs. EOF) {
document.write ("<tr>");
For (i=0 i <= fdcount; i++)
document.write ("<td valign= ' top ' >" + objRS.) Fields (i). Value + "</td>");
document.write ("</tr>");
Objrs.movenext ();
}
document.write ("</table>");
}
Else
document.write ("No record in the database!<br>");
objRS. Close ();
Objdbconn.close ();
-->
</SCRIPT>
Manipulating Database instances
Copy Code code as follows:
<script language= "JavaScript" >
<!--
var objdbconn = new ActiveXObject ("ADODB. Connection ");
var strdsn = "Driver={sql Server}"; server= (local); Uid=sa; Pwd=111111;database=hljdatabase "; Need to modify your server address, username, password
Objdbconn.open (STRDSN);
Objdbconn.execute ("UPDATE table Set association = 0"); Please write your own execution statement
document.write ("Update data successfully!<br>");
Objdbconn.close ();
-->
</SCRIPT>