當前位置:成語大全網 - 新華字典 - 如何在頁面上用node.js調用mdb數據庫

如何在頁面上用node.js調用mdb數據庫

1,跨進程通信

nodejs新版本中增加了子進程的操作,跨進程通信不成問題。

/en-us/library/windows/desktop/aa 746471% 28v = vs . 85% 29 . aspx

復制代碼代碼如下:

var connection = new ActiveX object(" ADODB。連接”);

var result = ' ok

嘗試{

聯系。Open("Provider=Microsoft。Jet . OLEDB.4.0數據源= "+params . access file);

聯系。執行(params . SQL);

} catch(ex){

result = ex.message

}

返回{

結果:結果

};

connection . open(connectionstring),鏈接字符串參數可以設置對sql server的訪問。

參考:/sql-server-2005

3.為了維護方便,將cscript和nodejs的腳本進行了合並,通過導出的類型來判斷當前運行的環境。

4.字符編碼cscript代碼使用ascii編碼。

非ascii字符用“\ uhhh”Unicode編碼。

5.命令行字符需要轉義,雙引號和百分號在命令行上有特殊含義。

參數傳遞使用base64編碼來避免沖突。

Cscript環境MSXML2。DOMDocument可以做base64編解碼。

復制代碼代碼如下:

函數base64Decode(base64){

var XML DOM = new ActiveX object(" MSXML 2。DOM document ");

var adostream = new ActiveX object(" ADODB。stream”);

var temp = XML DOM . createelement(" temp ");

temp . datatype = " bin . base64 ";

temp.text = base64

adostream。charset = " utf-8 ";

adostream。type = 1;//1 = ad type binary 2 = ad typetext

adostream。open();

adostream。write(temp . nodetypedvalue);

adostream。位置= 0;

adostream。type = 2;//1 = ad type binary 2 = ad typetext

var result = adostream。read text(-1);// -1=adReadAll

adostream。close();

adostream = null

xmldom = null

返回結果;

}