System.Data.EvaluateException HResult=0x80131920 Message=Cannot perform '=' operation on System.Int32 and System.String

-1
public void MatchedDocumentsInFileCabinet(string MainFolder, string SubFolder, string FileName, string FilePath)
{
    // Checking Main Folder is present in FileCabinet, if present retrieving MainFolderID if not Inserting MainFolderName

    if (SelectedFileCabinetID == "")
    {
        SelectedFileCabinetID = "1";
    }
    int Mainfoldercount = 0;

    DocSortResult getfolderdetails = objFolderManager.GetFolderDetails();
    DataTable getFolderNames = new DataTable();
    if (getfolderdetails.resultDS != null && getfolderdetails.resultDS.Tables[0].Rows.Count > 0)
    {
        // Following line is showing error
        DataRow[] drResult = getfolderdetails.resultDS.Tables[0].Select("FileCabinet_ID = '" + SelectedFileCabinetID + "'" + "and" + " ParentFolderID = '" + "0" + "'" + "and" + " IsDelete = '" + "True" + "'");
        if (drResult.Count() != 0)
        {
            getFolderNames = drResult.CopyToDataTable();
        }
    }
}
c#
asked on Stack Overflow Jul 27, 2018 by cheguri saikumar • edited Jul 27, 2018 by Cleptus

1 Answer

1

Without knowing getfolderdetails.resultDS.Tables[0] structure is hard to know which column is, but one of those columns is integer and your Select(filter) is telling that all the fields are string.

An example of your code debugging would show .Select("FileCabinet_ID = '4' and ParentFolderID = '0' and IsDelete = 'True' "). And the error message says one of them is not a string.

I would bet that IsDelete = 'True' probably will be boolean (bit column in SQL Server) and FileCabinet_ID or ParentFolderID or both of them are integer (and this is causing the error).

Set a breakpoint and check the datatypes of the datacolumns you are trying to filter.

answered on Stack Overflow Jul 27, 2018 by Cleptus

User contributions licensed under CC BY-SA 3.0