Home > Database > Mysql Tutorial > 如何判断ACCESS数据表中的某条记录是否存在

如何判断ACCESS数据表中的某条记录是否存在

WBOY
Release: 2016-06-07 15:42:45
Original
2505 people have browsed it

判断 方法为: OleDbConnectioncon=newOleDbConnection(连接字符串); stringname=test; con.Open(); OleDbCommandcmd=newOleDbCommand(selectcount(*)fromstudentDetailswheresname='name',con); intcount=Convert.ToInt32(cmd.ExecuteScalar()); con.Close(


判断方法为:

OleDbConnection con=new OleDbConnection("连接字符串");
string name="test";
con.Open();
OleDbCommand cmd=new OleDbCommand("select count(*) from studentDetails where sname='"+name+"'",con);

int count=Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
if (count>0)
{
  //说明记录存在..
}
else
{
  //说明记录存在..
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template