connect to database using javascript
-
I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox
-
I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox
Try posting this in the Javascript forum?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
-
I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox
As mentioned you should have posted this to the JavaScript forum. ActiveXObject is an IE object and not officially supported in FireFox, AFAIK. Most importantly though you are exposing the details of your database, username, password, table, table structure; a huge breach of security.
I know the language. I've read a book. - _Madmatt
-
I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox
-
I have to Get data from database and fill data into ListBox using javascript. I did like below var strConn = 'Provider=SQLOLEDB;server=localhost;user id=sa;pwd=***;initial catalog=xxx;'; var cn = new ActiveXObject("ADODB.Connection"); cn.open(strConn); var rs = new ActiveXObject("ADODB.Recordset"); rs.Open('SELECT EmpId,Name FROM Employee', cn); rs.MoveFirst while(!rs.eof) { var opt = document.createElement("Option"); opt.text = rs.fields(1); opt.value = rs.fields(0); document.getElementById(ListBoxCtrlName).options.add(opt); rs.movenext; } rs.close; cn.close; This is working fine in IE only when access datasource across domains enabled otherwise listbox not getting data.How can I fix this issue in IE And FireFox