Elizabeth,
Maybe try adding quotes around the field name "Status" like this.
qf.WhereClause = "\"Status\" = 'M' OR \"Status\" = 'T'";
I am to 100% sure but I found a link to the IQueryFilter doc that states "If you are querying data in a file geodatabase, shapefile, dBase table, coverage, INFO table, then field names are enclosed in double quotes:"
Brad
You two, Brad Niemand and Joe Borgione, have been such a great help to me. I think we have it working pretty well now. Thank you both so much for walking me through my issues. I believe the biggest issue what the addresses. I wondered if they had to be split out like that. I will hopefully remember for next time. You two are amazing. Thank you so much!!
Glad you got things going in the right direction!
Yeah I see where that error about the owner SID. It seems to happen when a call can't be plotted. I have one test address that isn't in the geocode and it throws that error.
Nevermind, I think that was on my end. I was looking for a lat/long fields to be 0 value, but in the data, those fields are empty. So i put tick marks around the '0' and check for empty string as well.
pQFiltXY.WhereClause = "\"status\" = 'U' AND (\"LonX\" <> '0' AND \"LonX\" <> '') AND (\"LatY\" <> '0' AND \"LatY\" <> '')";
UPDATE - I do get an error when I try to refresh my calls. It is supposed to delete all the new geocoded files that were created from the csv file and replace them with new ones, but some of the files get locked because they are in the map (my ActiveCalls layer) and then this throws an error. I haven't had to remove the layer before deleting the files before. Even removing the layer, I still get files locked that can't be deleted until I close my map. Any ideas?
I'm nothing of an arc objects guy, however, ArcMap is famous for locking down files until the program exits. Is the a particular reason you are sticking with the arc objuts approach over something like python?
I have limited time to do a total rewrite at this time. I think the issue is when I am getting the record count, I am opening the feature class. How do I close it?
// Get number of records plotted
IWorkspaceFactory2 wFactory = (IWorkspaceFactory2)new ShapefileWorkspaceFactory();
IWorkspace wSpace = wFactory.OpenFromFile(localMapFolder, 0);
IFeatureClass fClass = ((IFeatureWorkspace)wSpace).OpenFeatureClass("ActiveCalls"); // Opening class
ITable geoTable = (ITable)fClass;
IQueryFilter QF = new QueryFilterClass();
//QF.WhereClause = "Statis = 'M' OR Status = 'T'";
recordCount = geoTable.RowCount(null);
Elizabeth,
I don't know if this will fix it but you can give it a try. At the end of some of my test code, I do the following for a lot of the ArcObjects COM objects to clean them up so that they are not getting held onto by lazy .NET garbage collection.
if (workspace != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(workspace);
workspace = null;
}
if (ocatorWorkspace != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(locatorWorkspace);
locatorWorkspace = null;
}
Then I call into this helper method I created:
cleanupCOM();
Here it is:
public void cleanupCOM()
{
do
{
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
}
while (System.Runtime.InteropServices.Marshal.AreComObjectsAvailableForCleanup());
CoFreeUnusedLibraries();
}
You can try doing that for the interfaces like IWorkspaceFactory2, IWorkspace, IFeatureClass, etc....
Brad
Unfortunately, that did not help. I can't get rid of those locks unless I close the map. I can't do that everytime my calls get updated. When the csv file is recreated, it gets re-geocoded. So how can I get rid of that lock without having to reload my map control? It seems to be when I add that new layer created from the CSV.
UPDATE:
This could be causing the lock:
GP.Execute("GeocodeAddresses_geocoding", parameters, null);
I have released the com object and set to null and it is still locked.
Elizabeth,
You released the IGeoProcessor COM object, is that what you are saying? Have you tried using a FGDB instead of a Shapefile? I have test code that geocodes a table, counts the geocoded features and then deletes the result and I have no locking issues so I don't think it is the GP.Execute() code that is doing this. It might be time to call tech support if you are still having issues. Maybe a tech support SDK specialist will have some additional suggestions for you.
Brad
I don't know what a FGDB is. I have only worked with this code. It was written by a co-worker who no longer works with us, so I am left with a huge learning curve on top of modifying to a newer version. So whatever would help, I would be incredibly grateful.
I went back to look at opening the csv file, I figured out why that wasn't working. I was supplying the whole path instead of just the file name. But now I am having issues creating the Feature class. The error message don't help at all. It just says something went wrong.