|
POST
|
Ken, thank you, that did it!! James, thanks for trying..haha! We call the field FileNumber and it's a String Field, because File Numbers can be alpha-numeric 😉 Yes! Glad you are up and running, Dave. Contributors like Ken make this place such a great resource. You sent me off on a research stint for a while as I have recently found myself moved into more of a database/data modeling role. The naming of your field �??FileNumber�?� and not storing actual numbers but rather alpha-numeric/character string values made me take a closer look at some existing table structures we have. Initially, I thought your problem might have been related to placing single quotes around the FileNumber value in your where clause. And I think this could actually be a potential issue for some, and prove to be a headache for developers in larger organizations certainly. It might seem like a nitpick, but it sounds like that field is really more of a unique identifier: "File_Id". "FileNumber" seems like it should model an actual number rather than a . Obviously it works for you all -- I am just a big proponent of modelling database objects as closely as what they should represent. It has actually been a benefit over the long run in following that approach. So then I was asking myself, �??why would anyone want to name a field that holds character values with �??Number�?� in the name?�?�. I posed this on the MSDN forums and got an excellent reply. Basically, my curiosity as to why you would name your character field with �??Number�?� in the name can be explained by how we all are conditioned to hearing things. For example, when asked to write my Driver�??s license it typically asks �??write your Driver�??s License NUMBER�?�. Well, it isn�??t *really* a number, rather it�??s a string of characters and numbers. However, it could be important in database design and implementation, as well as programming against that database design, to make that distinction clear and name something what it really is.
... View more
07-13-2012
11:18 AM
|
0
|
0
|
1698
|
|
POST
|
James, credit was given to Ken. Ken usually always figure out my problems, so I'm never shy to give him credits..haha! The WhereClause is fine. You need single quotes to query strings. The code doesn't produces an error, it just act like the query is always true, even when it's not. 😄 So 175980 is a string? hmmmmmm. "FileNumber" suggests it is a whole number. May want to have a talk with the SDE administrator! 😄 Sorry I couldn't help more.
... View more
07-13-2012
07:12 AM
|
0
|
0
|
1698
|
|
POST
|
Ken's code does find the table, but I'm having problem with what it returns to work with the PerformAttributeQuery snipet. This is what I have, which always end up to the Exception Error Message.:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim pMap As IMap = My.ArcMap.Document.ActiveView
Dim queryFilter As String = "FileNumber = '175980'"
PerformAttributeQuery(GetTable("CSJGISSDE.GISDATA.Subdivision_Plans_Table", pMap), queryFilter)
Catch ex As Exception
MsgBox("This action cannot be done. Save your project, then restart ArcMap.")
End Try
End Sub
Public Function PerformAttributeQuery(ByVal table As ESRI.ArcGIS.Geodatabase.ITable, ByVal whereClause As System.String) As ESRI.ArcGIS.Geodatabase.ICursor
Dim queryFilter As ESRI.ArcGIS.Geodatabase.IQueryFilter = New ESRI.ArcGIS.Geodatabase.QueryFilterClass()
queryFilter.WhereClause = whereClause ' create the where clause statement
' query the table passed into the function and use a cursor to hold the results
Dim cursor As ESRI.ArcGIS.Geodatabase.ICursor = table.Search(queryFilter, False)
Return cursor
End Function
Private Function GetTable(ByVal InTableName As String, ByVal pMap As IMap) As ITable
Dim pStTabColl As IStandaloneTableCollection
pStTabColl = pMap
For j As Integer = 0 To pStTabColl.StandaloneTableCount
If (pStTabColl.StandaloneTable(j).Name = InTableName) Then
Return pStTabColl.StandaloneTable(j)
End If
Next j
Return Nothing
End Function
Ah. I was under the impression that his code didn't work. It does, please give him some credit!!! I was also misunderstanding you and thinking you couldn't just get the ITable reference. I don't see the error message (didn't make it into your last post). But the only thing I do notice is in your WHERE clause, you are wrapping what appears to be an integer/whole value into single quotes: Dim queryFilter As String = "FileNumber = '175980'" maybe change this to: Dim queryFilter As String = "FileNumber = 175980" Hope that helps!!!
... View more
07-13-2012
06:54 AM
|
0
|
0
|
1698
|
|
POST
|
Thanks James, but that didn't work. I think it's because you make reference to a Feature Class Table. I want to query a Single (stand-alone) Table, that's inside an SDE. I can't believe how complicated this is..lol Ken's approach didn't work? (sorry I cannot test this right now). What exactly happens? Perhaps you passed in the incorrect name (I think there are some strict requirements for SDE referenced tables perhaps. you might need to add the schema name in the table name "dbo.TableName" --- not sure). Private Function GetTable(InTableName As String, pMap as IMap) As ITable
Dim pStTabColl As IStandaloneTableCollection
pStTabColl = pMap
For j as Integer = 0 To pStTabColl.StandaloneTableCount
If (pStTabColl.StandaloneTable(j).Name = InTableName) Then
Return pStTabColl.StandaloneTable(j)
End If
Next j
Return Nothing
End Function
... View more
07-13-2012
06:35 AM
|
0
|
0
|
2378
|
|
POST
|
Thanks Ken. I'm trying to access an SDE Table that's already loaded in ArcMap. I just need to know how to assign the table (by its name), in the same fashion as you would assign a Feature Class by it's name. Try:
'assumes you have set your m_pApp reference already
Dim i As Integer
Dim pLayer As IFeatureLayer
pLayer = Nothing
pDoc = m_pApp.Document
pMap = pDoc.FocusMap
For i = 0 To pMap.LayerCount - 1
If pMap.Layer(i).Name = "Your SDE Table Name Here" Then
pLayer = pMap.Layer(i)
Exit For
End If
Next
'now set your ITable
Dim pTable As ITable
Set pTable = pLayer.FeatureClass
... View more
07-13-2012
06:12 AM
|
0
|
0
|
2378
|
|
POST
|
Not sure if you can do want you want via that LayerContextMenuItems. You might have to manipulate the settings through ILabelEngineLayerProperties. See here for a possible alternative solution: http://forums.arcgis.com/threads/20019-Set-Expression-to-DisplayField?highlight=set+label+field
... View more
07-12-2012
07:35 AM
|
0
|
0
|
468
|
|
POST
|
I am very limited in Add-in development experience so apologies if this is not pertinent to your issue, but I came across this post that might help.... http://forums.arcgis.com/threads/909-Beta-10-Locating-AddIn-Extension-from-a-Button?highlight=add-in+icommandbar.find
... View more
07-11-2012
10:40 AM
|
0
|
0
|
1056
|
|
POST
|
As stated above, you can call the GeoProcessor. You could also create a PGD and add it to your build, in code, simply copy from the assembly directory to which ever directory you wish and rename. ' Create a file geodatabase workspace factory. Dim factoryType As Type = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory") Dim workspaceFactory As IWorkspaceFactory = CType(Activator.CreateInstance(factoryType), IWorkspaceFactory) ' Create a file geodatabase. Dim workspaceName As IWorkspaceName = workspaceFactory.Create("C:\Data", "California", Nothing, 0) In addition to Mike's suggestion above, if you can also include this PGDB in any deployment package you might create and have the installer move the PGDB to the client machine during any installation process for your development. I don't remember off-hand the exact code, but instead of hardcoding the location ("C:\Data" or wherever it sits) you would specify the application path in your assembly. This works very well in an implementation I have where the PGDB acts as sort of a container of empty feature classes and tables that are dynamically populated and depleted per the functionality of the application.
... View more
07-11-2012
07:28 AM
|
0
|
0
|
1293
|
|
POST
|
Hi jamesfreddyc, Thanks for the reply. Unfortunately I have no control over anything on the design side of things. I was hoping that the attrib index was stored locally on the machine used to create it so that I could add a little code to create the index periodically on the end users machines. Forgive me (I am still a novice at a lot of this stuff), I have never had experience with stored procedures...is this something I can set up on the client side? My application uses an attribute search to select features and then creates a selection layer from these. It then zooms to the selection layer and uses this as an area of interest to spit out some automated maps. In this I don't need to display the attributes as such, I do have some routines that grab a few bits and pieces out of the selection layer for legend details but that's about it. Thanks again! I see. My suggestion wouldn't really offer any benefit since your requirement is to apply a selection on the layer and zoom functionality. Since you are dealing with queries on a SDE layer, I would think that the index would have to be applied on the database that the layer is stored in. You can verify that in the SDE forums or hopefully someone here can confirm that, but that just seems logical to me. In thinking about this, I've never had to really worry about indexes because the SDE administrator I work with is very good and has tuned the database to required spec and as a result the development work I do goes smoothly. Can you inquire with your DBA/SDE admin person or group about this? See if an index is even applied to the field you are querying on AND if it is a good idea to have one (it *may* be a case where too many indexes hurt performance!). Again, you should check with the folks who are maintaining the db/sde environment. Or perhaps someone here can confirm that your idea of a local index is valid or not.
... View more
07-11-2012
03:53 AM
|
0
|
0
|
934
|
|
POST
|
Hi, I have a layer with 3mil+ polygon features of fairly simply geometry which I need to perform attribute queries on using a custom application I am developing. The layer sits within an SDE and I need to attempt to improve performance as currently the query can take a while to run. My question is two fold: If I index the search field on this layer is that index stored locally on the machine accessing the SDE? And further, if this is true, when the dataset gets updated (I think it is weekly) will I be notified that it needs to be re-indexed somehow or will I need to re-index at regular intervals? Any other performance hints and tips anyone can give me will be well appreciated too. I am using VB.Net and ArcGIS 10. Thanks in advance. Edit: your index(es) should be applied to the SDE layer under the design approach defined by the SDE administrator. Additionally, logfile management should be implemented as this could potentially be a source of your peformance issues. Is the data versioned? If it is just attribute querying and not on the geometry, maybe consider a parameterized Stored Procedure along with a DataGridView for displaying the result? (you say this is part of a custom app and I suspect you have UI elements you are creating for attribute display and manipulation). It is my understanding that the SProc's execution plan will be pre-compiled on the server and aids in peformance. I have several apps that utilize this approach and it works very well --- parcels as geometries and SDE table as attributes with a parameterized StoredProcedure setup for queries on the SDE table. I don't have direct answers to your other two questions, but I'd take a guess that you or your DBA will have to re-index after updates. You might want to double-check/verify that in the SDE forum.
... View more
07-10-2012
04:10 AM
|
0
|
0
|
934
|
|
POST
|
Use IFeaturelayerDefintion and set the .DefinitionExpression with your SQL edit: oops sorry Ken, you were first!
... View more
07-06-2012
07:09 AM
|
0
|
0
|
2278
|
|
POST
|
Before any of the processing code runs, can you simply loop through the TOC and set each layer's visibility to false? (not sure if it'd help, but it is fairly simple to implement this). It'd be something like this: (I just pulled this from another thread, you should fully test it on something simple first): 'also, you'd need to set your pDoc and pMap references before too!
Dim pLayer as IFeatureLayer
For intCount = 0 To pMap.LayerCount - 1
pLayer = pMap.Layer(intCount)
pLayer.Visible = False
Next
... View more
07-05-2012
09:49 AM
|
0
|
0
|
1122
|
|
POST
|
right format is,"Datefield" = date 'yyyy-mm-dd' the sql is,"insert into TB1(ClmD) values(date '2012-1-1')" http://help.arcgis.com/en/arcgisdesktop/10.0/help/#/SQL_reference_for_query_expressions_used_in_ArcGIS/00s500000033000000/ this page has the detail about query expressions I believe it all depends upon your underlying database (is it SQL Server, Oracle, etc??) as to how you need to write it to the database. You say "gdb", but what is the database? And does your date field in the db contain the time portion of the date? All of these factors will affect how you need to store values.
... View more
06-29-2012
04:01 AM
|
0
|
0
|
1125
|
|
POST
|
Thanks for the code jamesfreddyc... best example I've found. Thank you very much for the compliment! Glad you could use it.
... View more
06-13-2012
05:08 AM
|
0
|
0
|
2147
|
|
POST
|
Here's what I have done with Neil's approach: I use this as a Private function throughout my assemblies and works well when I have support files that need to be accessed or written to and are/have been deployed with the application when installed. Private Function GetAppPath() As String
Dim path As String
path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location)
Return path
End Function So to use this, here is an example of how I might setup a connection string to an Excel file that was included in the original deployment/install of the application: Dim m_sConn1 As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & GetAppPath() & "\" & inDist & ".xlsx;;Extended Properties=""Excel 12.0 Xml;HDR=Yes"""
Dim ExcelConnection As New System.Data.OleDb.OleDbConnection(m_sConn1)
ExcelConnection.Open()
... View more
01-12-2012
07:01 AM
|
0
|
0
|
3778
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-17-2020 10:47 AM | |
| 1 | 10-25-2022 11:46 AM | |
| 1 | 08-08-2022 01:40 PM | |
| 1 | 02-15-2019 08:21 AM | |
| 2 | 08-14-2023 07:14 AM |
| Online Status |
Offline
|
| Date Last Visited |
01-22-2025
02:28 PM
|