<!doctype html>
<html>
<title>Search</title>
<script type="text/javascript">
function query() {
var adVarWChar = 202;
var adParamInput = 1;
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 cm = new ActiveXObject("ADODB.Command");
cm.ActiveConnection = cn;
cm.CommandText = "SELECT * FROM ImportFromExcel WHERE Module LIKE ? OR TestCase LIKE ? OR Openedby LIKE ? OR Status LIKE ?";
//cm.CommandText = "SELECT * FROM ImportFromExcel where TestCase LIKE ?";
cm.Parameters.Append(cm.CreateParameter(
"?",
adVarWChar,
adParamInput,
255,
"%" + document.getElementById("searchTerm").value + "%"));
var rs = cm.Execute(); // returns ADODB.Recordset object
if (rs.EOF) {
document.write("<p>No data found.</p>");
} else {
while (!rs.EOF) {
document.write("<p>" + rs.fields(0).value + ", ");
document.write(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 + ".</p>");
var row = row.parentNode.rows[ ++idx ];
document.write(rs.fields(1).value + ".</p>");
rs.MoveNext();
}
}
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>
请帮我修改SELECT语句,使其覆盖整个表(不仅仅是“TestCase”列)?
尝试将SELECT查询更改为“SELECT * FROM ImportFromExcel WHERE col1 LIKE?OR col2 LIKE?or col3 LIKE?; ...”,但它无效。
答案 0 :(得分:2)
如果要在表格的所有列中搜索字符串 您可以连接新列中的所有列值和搜索值。例如
SELECT * FROM ImportFromExcel
WHERE Module
& column1
& column2
& column3 like '*substring*'