我正在尝试使用 javascript 检查记录是否存在(我知道这不是最安全的方法),但所有这些都是供内部使用的,安全不是问题。
于是我打开了一个记录集,
rs.Open("SELECT * FROM clie Where N_CLIENT =" + textbox1+ " AND C_POST_CLIENT = '" + textbox2+ "'",connection)
textbox1
并且textbox2
是我正在查看 clie 表的值,但首先我需要检查记录是否存在。我尝试将其分配rs.Open
给一个变量,然后将其与某些东西进行比较,但它不起作用
我尝试使用 aRecordCount
但我一直得到-1。我读到它不是为此而设计的,它不应该用于查找记录,因此必须有另一种方法来做到这一点。
更新_
这是我正在处理的整个功能
function RecordExists(textfield1, textfield2)
{
var connection = new ActiveXObject("ADODB.Connection") ;
var connectionstring = "UID=admin;PWD=password";
connection.Open(connectionstring);
var rs = new ActiveXObject("ADODB.Recordset");
var textbox1= new String();
var textbox2=new String();
textbox1= document.getElementById(textfield1).value;
textbox2= document.getElementById(textfield2).value;
var isEmpty=new String();
rs.Open("SELECT count(*) as pers FROM clie HAVING N_CLIENT =" + textbox1+ " AND C_POST_CLIE = '" + textbox2+ "'",connection);
alert(rs.recordcount);
//alert(rs.fields(1));
//isEmpty = rs.Open("pers");
alert("Empty"+isEmpty);
if(pers=0)
alert("Record does not exist! pers="+pers);
else if(pers=1)
alert("Record exists! pers="+pers);
else
alert("not working");
rs.close;
connection.close;
}
}