It is often used to determine whether the database has the same data. Is there any other method besides select? I would like to ask you here!
Sample Code in (urladd. aspx. CS)
// Determine whether the website exists
If (navigation. beurl (URL ))
{
Sperror. innertext = "you already have a database! ";
Return;
}
Query whether the website has a database
Public static bool beurl (string URL)
{
String SQL = "select count (1) from [navurl] Where [url] = @ URL ";
Sqlparameter parameters = new sqlparameter ("@ URL", sqldbtype. varchar, 50 );
Parameters. value = URL;
Return dbhelper. exists (SQL, parameters );
}
Dbhelper code
# Check whether the same data exists in the Region Query
Public static bool exists (string strsql)
{
Object OBJ = dbhelper. getsingle (strsql );
Int cmdresult;
If (object. Equals (OBJ, null) | (object. Equals (OBJ, system. dbnull. Value )))
{
Cmdresult = 0;
}
Else
{
Cmdresult = int. parse (obj. tostring ());
}
If (cmdresult = 0)
{
Return false;
}
Else
{
Return true;
}
}
Public static bool exists (string strsql, Params sqlparameter [] partition parms)
{
Object OBJ = dbhelper. getsingle (strsql, limit parms );
Int cmdresult;
If (object. Equals (OBJ, null) | (object. Equals (OBJ, system. dbnull. Value )))
{
Cmdresult = 0;
}
Else
{
Cmdresult = int. parse (obj. tostring ());
}
If (cmdresult = 0)
{
Return false;
}
Else
{
Return true;
}
}
# Endregion