///
/// 检测一个记录是否存在(SQL语句方式)
///
public static bool Exists(string strSql)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetSqlStringCommand(strSql);
object obj = db.ExecuteScalar(dbCommand);
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;
}
}
/// 检测一个记录是否存在(SQL语句方式)
///
public static bool Exists(string strSql)
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetSqlStringCommand(strSql);
object obj = db.ExecuteScalar(dbCommand);
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;
}
}
执行SQK语句
获取获取值
DbCommand dbCommand = db.GetSqlStringCommand(strSql);
只需要解释这两句就好了