I have an MS Access Database Table 'ImportFromExcel' having 16 columns. When 'Search' key in the webpage is pressed after entering keyword(s), it should go to table and check if the keyword(s) is/are present anywhere in the table. If the keyword is present in a row, that row should be printed. Else, it should throw a message.
Code:
<!doctype html>
<html>
<title>Search</title>
<script type="text/javascript">
function query()
{
var pad = "C:\\Users\\azi!z\\Desktop\\Project\\Test.accdb";
var cn = new ActiveXObject("ADODB.Connection");
var strConn = "Provider=microsoft.ace.oledb.12.0;Data Source=" + pad;
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
var SQL = “SELECT * FROM ImportFromExcel where TestCase ALIKE '%searchTerm%'”;
rs.Open(SQL, cn);
if(!rs.bof)
{
rs.MoveFirst();
if(!rs.eof)
{
document.write("<p>" + rs.fields(1).value + ", ");
document.write(rs.fields(2).value + ", ");
document.write(rs.fields(3).value + ", ");
document.write(rs.fields(4).value + ", ");
document.write(rs.fields(5).value + ", ");
document.write(rs.fields(6).value + ", ");
document.write(rs.fields(7).value + ", ");
document.write(rs.fields(8).value + ", ");
document.write(rs.fields(9).value + ", ");
document.write(rs.fields(10).value + ", ");
document.write(rs.fields(11).value + ", ");
document.write(rs.fields(12).value + ", ");
document.write(rs.fields(13).value + ", ");
document.write(rs.fields(14).value + ", ");
document.write(rs.fields(15).value + ", ");
document.write(rs.fields(16).value + ".</p>");
}
}
else
{
document.write("No data found");
}
rs.Close();
cn.Close();
}
</script>
</head>
<body>
<form method="get" name="SearchEngine" target="_blank">
<p style="text-align: center;"><span style="font-family:times new roman,times,serif;"><span style="font-size: 36px;"><strong>EA Search Engine</strong></span></span></p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"><input maxlength="300" id="searchTerm" name="KeywordSearch" size="100" type="text" value="Enter Your Keyword Here" /></p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"><input name="Search" type="button" value="Search" onclick="query();" /></p>
</form>
</body>
</html>
Tried the query in MS Access and it's giving the expected result (Thanks to @HansUp). Seems to be a problem with the JavaScript piece. Please help :)