使用like查询text类型字段
public bool Exists(GetReadType GRT, ClientMessageGetRead TypeID, string MessageID, string UserID)
{
int ThisGRT = Convert.ToInt32(GRT);
int ThisTypeID = Convert.ToInt32(TypeID);
string strSql = @"
select
count(1)
from
Client_Message_GetRead
where
GetRead = @GetRead
and
TypeID = @TypeID
and
MessageID like '%'+@MessageID+'%'
and
UserID = @UserID
"; SqlParameter[] parameters = {
new SqlParameter("@GetRead", SqlDbType.Int,),
new SqlParameter("@TypeID", SqlDbType.Int,),
new SqlParameter("@MessageID", SqlDbType.Char,),
new SqlParameter("@UserID", SqlDbType.Char,)
};
parameters[].Value = ThisGRT;
parameters[].Value = ThisTypeID;
parameters[].Value = MessageID;
parameters[].Value = UserID; return DbHelperSQL.Exists(strSql.ToString(), parameters);
} public DataSet NotExists1(GetReadType GRT, string CompanyID, string UserID)
{
int ThisGRT = Convert.ToInt32(GRT);
int ThisTypeID = Convert.ToInt32(ClientMessageGetRead.公益团体消息);
string strSql = @"
select
*
from
Company_Company_Message
where
CompanyID = @CompanyID
and
(
select
top 1 MessageID
from
Client_Message_GetRead
where
GetRead = @GetRead
and
TypeID = @TypeID
and
UserID = @UserID
)
not like '%'+MessageID +'%'
"; SqlParameter[] parameters = {
new SqlParameter("@GetRead", SqlDbType.Int,),
new SqlParameter("@TypeID", SqlDbType.Int,),
new SqlParameter("@CompanyID", SqlDbType.Char,),
new SqlParameter("@UserID", SqlDbType.Char,)
};
parameters[].Value = ThisGRT;
parameters[].Value = ThisTypeID;
parameters[].Value = CompanyID;
parameters[].Value = UserID; return DbHelperSQL.Query(strSql.ToString(), parameters);
}