如何判斷ACCESS數(shù)據(jù)表中的某條記錄是否存在
來源:懂視網(wǎng)
責(zé)編:小采
時(shí)間:2020-11-09 15:30:04
如何判斷ACCESS數(shù)據(jù)表中的某條記錄是否存在
如何判斷ACCESS數(shù)據(jù)表中的某條記錄是否存在:判斷 方法為: OleDbConnectioncon=newOleDbConnection(連接字符串); stringname=test; con.Open(); OleDbCommandcmd=newOleDbCommand(selectcount(*)fromstudentDetailswheresname='name',con); int
導(dǎo)讀如何判斷ACCESS數(shù)據(jù)表中的某條記錄是否存在:判斷 方法為: OleDbConnectioncon=newOleDbConnection(連接字符串); stringname=test; con.Open(); OleDbCommandcmd=newOleDbCommand(selectcount(*)fromstudentDetailswheresname='name',con); int

判斷 方法為: 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
{
//說明記錄不存在..
}
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
如何判斷ACCESS數(shù)據(jù)表中的某條記錄是否存在
如何判斷ACCESS數(shù)據(jù)表中的某條記錄是否存在:判斷 方法為: OleDbConnectioncon=newOleDbConnection(連接字符串); stringname=test; con.Open(); OleDbCommandcmd=newOleDbCommand(selectcount(*)fromstudentDetailswheresname='name',con); int