--select * from jobs
use pubs
if(select count(*) from jobs where job_id=32)> 0 print '有记录 '
else print '无记录 '
方法二:
if exists(select top 1 1 from jobs where job_id=32 ) print '有记录 '
else print '无记录 '
js函数中如何判断返回值的大小。
将满足条件的记录总数给文本框进行比较。
function UserDefineDjSave()
{
var s1= document.all.combobox1.value;
var s2= document.all.combobox2.value;
var s3= document.all.combobox3.value;
var sSql="select mainid as t from PriorToCapDistribution where 1=1";
sSql +=" and Department ='"+s1+"' and Year='"+s2+"' and Month='"+s3+"' ";
dataset1.Open(sSql);
//document.all.txtRecordNum.innerText = dataset1.RecordCountAll;
document.all.txtRecordNum.value = dataset1.RecordCountAll;
var a="";
a=document.all.txtRecordNum.value;
if(s1=="")
{
alert("请选择部门");
return;
}
if(s2=="")
{
alert("请选择年份");
return;
}
if(s3=="")
{
alert("请选择月份");
return;
}
if (s1!=""&&s2!=""&&s3!=""&&(a)>1)
{
alert("本年月的记录已录入过!!!");
return;
}
else
{
DjSave();
}
}