Friday, March 20, 2009

local mdb data export to website backend mysql

Problem: Laboratory Machine connected with rs232 update .mdb file on Local computer. We have to fetch this data from web page (web site running on service provider IIS/Apatche server) and send it to website Back-end MySql Server so everyone can use same data world wide.
Solution: Webpage in native PHP. write Javascript embedded into it with ADODB object...
var obj = new ActiveXObject("ADODB.Connection");
fetch data and assign it through document.getElementById and import to input tag name by same ID.
HTML:
input name=i1 type=text
JS:
document.getElementById("i1").value = jsVar;
PHP:
$PhpVar = $_GET["i1"]

To fetch Data from Local .mdb you can use systemDSN ODBC

var cObj = new ActiveXObject("ADODB.Connection");
var rS = new ActiveXObject("ADODB.Recordset");

rS.CursorLocation = adUseClient;
cObj.CursorLocation = adUseClient;

var iStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:/userdata.mdb";
var adOpenKeyset = 1;
var adLockOptimistic = 3;
var adCmdText = 1;
var adUseClient = 3;
cObj.Open(systemDSN_Name) // or use cObj.Open(iStr)
var grStr = "SELECT * FROM table1 WHERE uid=12"



recSet.Open(grStr,cObj,adOpenKeyset,adLockOptimistic,adCmdText)
recSet.AddNew;
var id = rS.Fields("Name").value;
Important:
To Access SystemDSN from another Machine on your Intranet Pl share Folder with FullAceess(Read-Write) on which your .mdb file reside. If this ignore you will get Error: File already in use
Settings for IE:
access Data Source across domain - Prompt/Enable.
ActiveX Control/Script running - Prompt/Enable.

1 comment:

quanvanfabregas said...

Lucky 15 Casino & Hotel | Joliet - JTHub
Find out more about Lucky 15 Casino & Hotel in Joliet and other 태백 출장샵 Joliet 논산 출장안마 Hotels. 동두천 출장안마 JT 순천 출장안마 Rewards members can earn up to 10 free nights 경산 출장샵