I'm getting an error while filtering the search by OwnerId for Task object.
Following is what i'm doing and it is giving me an error : Error: Compile Error: expecting a semi-colon, found ' and OwnerId in :ownerIds' at line 106 column 142
public void queryTasks(){
String qStr2= searchText;
Set<Id> ownerIds = new Set<Id>();
String strnormal = '';
try{
mydate = date.parse(qStr2);
}catch(Exception e)
{ }
String strDate = '';
if(mydate != null) {
// strnormal = String.valueOf(mydate );
String[] qstr3 = String.valueOf(mydate).split(' ',2);
strDate = ' ActivityDate = '+ qstr3[0] + ' ';
}else{
strDate = 'Subject like \'%'+searchText +'%\' OR Status like \'%' +searchText+ '%\' Order By ' + sortField;
}
if (ownerIds != null && ownerIds.size() > 0){
String qStr = 'Select OwnerId,Subject,Status,ActivityDate from Task where '+strDate+' limit ' + QueryLimit + ' offset ' + OffsetSize' and OwnerId in :ownerIds';
}
//String qStr ='Select OwnerId,Subject,Status,ActivityDate from Task where \''+strDate +'\' limit ' + QueryLimit + ' offset ' + OffsetSize;
// String qStr = 'Select OwnerId,Subject,Status,ActivityDate from Task where '+strDate+' limit ' + QueryLimit + ' offset ' + OffsetSize;
System.debug(qStr);
// String qStr = 'Select OwnerId,Subject,Status,Priority from Task where Subject like \'%'+searchText+'%\' OR Status like \'%'+searchText+ '%\' Order By ' + sortField;
tasks = Database.query(qStr);
//tasks.sort();
}