JavaScript 收集的两个小代码!

发表于:2008-05-30来源:作者:点击数: 标签:代码JavaScriptJavascriptjavascript收集
关键字: Java Script 代码 简单的 数据库 操作: HTML HEAD META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0" TITLE/TITLE script language= java script function connectDb() { var ConnDB = new ActiveXObject("ADODB.Connection"); ConnDB.
关键字:JavaScript 代码


简单的数据库操作:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<script language=javascript>
function connectDb()
{
 var ConnDB = new ActiveXObject("ADODB.Connection");
  ConnDB.ConnectionString="dsn=shbxdatabase;uid=ldbx;pwd=123456;"; 
  ConnDB.Open(); 
 var  Rs = new ActiveXObject("ADODB.Recordset");
 var tempstr="";
 Rs.Open("select * from WDA1",ConnDB,1,3);
 while(!Rs.EOF)
 {
  tempstr = tempstr + Rs("TNAME") + "<br/>";
  Rs.MoveNext;
 }
  test.innerHTML=tempstr;
 }
</script>
</HEAD>
<BODY onbeforeunload="return 'ok?'">

<P><div id=test> </div>
<P><INPUT id=button1 type=button value=显示 name=button1 onclick="connectDb()"></P>

</BODY>
</HTML>
>>>>>>-------------------------------------

var db="D:\\js\\9t\\db1.mdb";
function opendb(dbname,sql)
{
var opendb =new ActiveXObject("ADODB.Recordset")
opendb.ActiveConnection = "DBQ="+dbname+";DRIVER={Microsoft Aclearcase/" target="_blank" >ccess Driver (*.mdb)};"
opendb.Source = sql
opendb.CursorType = 1
opendb.CursorLocation = 2
opendb.LockType = 3
opendb.Open()
return opendb
}


 var rs=new Object();
 rs=opendb(db,"select * from 产品 where id="+i);
 document.all.xx1.innerHTML=rs("生产厂商").value;
 document.all.xx2.innerHTML=rs("产品名称")+"/"+rs("型号");
 document.all.xx3.innerHTML=rs("售价");
 document.all.xx4.innerHTML=rs("批发");
 document.all.xx5.innerHTML=rs("备注");
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---------------------------------------

原文转自:http://www.ltesting.net