+ Start a Discussion
Rajesh SFDCRajesh SFDC 

how to get case object for corresponding attachments using query in c#?

here i want to fetch the case object for corresponding all attachments
using casenumber

public void getFilesfromSalesforce(string strCaseno)
{
        try
        {
            binding = new SforceService();
            lr = binding.login(strUserName, strpassword);
            loginResult = lr;
            //SforceService salesforce = new SforceService();
            binding.SessionHeaderValue = new SessionHeader();
            binding.SessionHeaderValue.sessionId = loginResult.sessionId;
            binding.Url = loginResult.serverUrl;
           
            QueryResult qResult = null;
            //Enterprise.Attachment at = new Enterprise.Attachment();
            //at.
         
         String soqlquery2 = "SELECT Id, CaseNumber,Status FROM Case  where CaseNumber =:"+ strCaseno;
         String soqlQuery = "Select Id, ParentId From Attachment where ParentId = " + soqlquery2.CaseNumber; here i am getting an error malformed query

            qResult = binding.query(soqlQuery);

           
        }
        catch (Exception ex)
        {

          
        }
APN09217013342392059APN09217013342392059
You may want to modify the query from,
String soqlQuery = "Select Id, ParentId From Attachment where ParentId = " + soqlquery2.CaseNumber;

to

String soqlQuery = "Select Id, ParentId From Attachment where ParentId = ' " + strCaseno + " ' " ;


Rajesh SFDCRajesh SFDC
still i am getting a same error .INVALID_QUERY_FILTER_OPERATOR:
ParentId From Attachment where ParentId = ' 00001215 '
while using this query String soqlQuery = "Select Id, ParentId From Attachment where ParentId = ' " + strCaseno + " ' " ;