views:

388

answers:

2

my source is working in IE but not in mozilla. please help me.

<script type="text/javascript">
<!--
var adOpenDynamic = 2;
var adLockOptimistic = 3;

/* Path of database.
*/
var strDbPath = "..\\SRVGdb.mdb";

/*
Here is the ConnectionString for Microsoft Access.
If you want to use SQL or other databases, you hav to change the connection string..
eg: SQL => var conn_str = "Provider=sqloledb; Data Source=itdev; Initial Catalog=pubs; User ID=sa;Password=yourpassword";
*/
var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strDbPath;

function getAdoDb(strAdoType){
if (window.ActiveXObject){
return new ActiveXObject(strAdoType);
}
else{
return ActiveXObject(strAdoType);
}
}

function showReports(){
try{
var tablevar="<table width=\"100%\" border=\"1\">"
                    +"  <tr><td></td>"
                    +"  </tr>";

//Database Connection
var conn = getAdoDb("ADODB.Connection");
conn.open(conn_str, "", "");

//Recordset
var rs = new ActiveXObject("ADODB.Recordset");
strQuery = "SELECT * FROM GuestBook";
rs.open(strQuery, conn, adOpenDynamic, adLockOptimistic);

if(!rs.bof){
rs.MoveFirst();

while(!rs.eof) {

    if(document.layers){
     document.getElementById("one").open();

     document.getElementById("one").close();
    }
    else{

tablevar+="  <tr>"
                    +"    <td>"+"Sur Name: <br> Fore Name: <br> Home Address: <br> PinCode: <br> Contact Number: <br> E-mail: <br> Date of Birth: <br>  Nationality: <br> University: <br> Available Timings: <br> Interested Courses: <br> Other Courses:  <br> Expected Money:  <br> Any More Information: <br> "+"</td>"
                    +"    <td>"+rs.fields(0).value+"<br>"+rs.fields(1).value+"<br>"+rs.fields(2).value+"<br>"+rs.fields(3).value+"<br>"+rs.fields(4).value+"<br>"+rs.fields(5).value+"<br>"+rs.fields(6).value+"<br>"+rs.fields(7).value+"<br>"+rs.fields(8).value+"<br>"+rs.fields(9).value+"<br>"+rs.fields(10).value+"<br>"+rs.fields(11).value+"<br>"+rs.fields(12).value+"<br>"+rs.fields(13).value+"<br></td>"
      +"  </tr>";

    document.getElementById("one").innerHTML=tablevar;

}

    rs.MoveNext();
    }
}
else{

    if(document.layers){
     document.getElementById("one").open();

     document.getElementById("one").close();
    }
    else{

     document.all("one").innerHTML="No Records To Display.";

    }
//No Records.

}
conn.close();


tablevar+= "</table>";

}catch(ex){
alert(ex.message);
}
}

//-->
</script>

thanks in advance

+4  A: 

ActiveXObject is IE specific and you wont be able to execute that in a non IE browser.

rahul
how can i execute in firefox browser
Vikram Phaneendra
Don't execute this in the browser. It's really quite crazy to implement a guest book entirely in JavaScript, including the database interaction. Do this server-side with ASP.NET, PHP or something similar instead
asbjornu