javascriptを使用してレコードが存在するかどうかを確認しようとしています(これを行うのが最も安全な方法ではないことはわかっています)が、これはすべて内部使用であり、安全性は問題ではありません。
それで私はレコードセットを開きました、
rs.Open("SELECT * FROM clie Where N_CLIENT =" + textbox1+ " AND C_POST_CLIENT = '" + textbox2+ "'",connection)
textbox1
とtextbox2
は私がclieテーブルを調べている値ですが、最初にレコードが存在するかどうかを確認する必要があります。それを変数に割り当ててrs.Open
から何かと比較してみましたが、うまくいきませんでした
使ってみましたRecordCount
が、-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;
}
}