You need to sign in to do that
Don't have an account?
Filtered query problem .net C#
Hi,
I am having problems filtering my queries in C# .net. I downloaded the sample code, but I can't make them work.
I am trying to retreive 1 account based on its name.
If I hard code the Name field which is my filter, it works, if I pass a variable, it doesn't.
////////////////////////////////
private static void doGetAccounts()
{
//check to see if we are already logged in
if (lr == null)
{
Console.WriteLine("Run the login sample before the others.\n");
getUserInput("Hit enter to continue: ");
Console.WriteLine("\n");
return;
}
//create a variable to hold the query result
sforce.QueryResult qr = null;
// get user input for account name
String accName = getUserInput("Please enter the account name: ");
//call the query saving the results in qr
try
{
// non-working query
qr = binding.query("select Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry from Account where Name = " + accName);
// working query
qr = binding.query("select Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry from Account where Name = 'Chris'");
}
catch (Exception e)
{
Console.WriteLine(e.Message + "\n" + e.StackTrace);
return;
}
//////////////////////////
please help me out!. Sample queries would be awesome!
thank you,
chris
qr = binding.query("select Name, BillingStreet, BillingCity, BillingState, BillingPostalCode, BillingCountry from Account where Name = '" + accName + "'");