Return to Snippet

Revision: 43550
at March 26, 2011 02:51 by kashif21


Updated Code
function dblookup()
{
    var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\\sdi.mdb"; 

    var ConnectObj = new ActiveXObject("ADODB.Connection");
    var RS = new ActiveXObject("ADODB.Recordset");
    var sql="SELECT * FROM employeespulled WHERE empid='1';";

    ConnectObj.Open (myConnect);
    RS.Open(sql,ConnectObj,adOpenForwardOnly,adLockReadOnly,adCmdText);

    var fieldCount = RS.Fields.Count;
    alert("Field Count" + fieldCount);    
    RS.Close();
    ConnectObj.Close();
}

//////////////////////2nd methood//////////////////////////////////
<html>
<head>
 
<script language="JavaScript">
 
var cn = new ActiveXObject("SQLiteDb.Connection");
if (typeof(cn)=="undefined" || cn==null) 
 alert("Unable to create the connection object!");
else
 alert("Connection object was successfully created!");
 
var strConn = "Database=db/test.db";
function getdata(){
 cn.Open(strConn);
 var rs = new ActiveXObject("SQLiteDb.Recordset");
 var SQL = "SELECT CoName from Companies WHERE CoID=1";
 rs.Open(SQL, cn);
 alert(rs(0));
 rs.Close();
 cn.Close();
}
</script>
 
</head>
<body>
 
<input type="button" value="Get data"
onclick="getdata()">
</body>
</html>

Revision: 43549
at March 26, 2011 02:43 by kashif21


Initial Code
function dblookup()
{
    var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\\sdi.mdb"; 

    var ConnectObj = new ActiveXObject("ADODB.Connection");
    var RS = new ActiveXObject("ADODB.Recordset");
    var sql="SELECT * FROM employeespulled WHERE empid='1';";

    ConnectObj.Open (myConnect);
    RS.Open(sql,ConnectObj,adOpenForwardOnly,adLockReadOnly,adCmdText);

    var fieldCount = RS.Fields.Count;
    alert("Field Count" + fieldCount);    
    RS.Close();
    ConnectObj.Close();
}

Initial URL

                                

Initial Description

                                

Initial Title
sql query using javascript

Initial Tags
javascript, sql, query

Initial Language
JavaScript