Justin: May I humbly suggest that rather than calling a very nasty Visual Basic routine, you could do the entire thing in Python more simply. The following example uses an SQL query to obtain the same information as the VB you supplied (if I understood the VB correctly.) I think you'll find the Python a bit easier to read. -- Vernon <code> def ListUniqueRecords(): import adodbapi as db connection_string = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s' dbFile = "C:\MyPath\MyGDB.mdb" Workspace = db.connect(connection_string % dbFile) Curs = Workspace.cursor() Curs.execute('select distinct VAL from MyTableName') for val in Curs.fetchall(): print(val[0]) Curs.close() Workspace.close()
if __name__ == "__main__": ListUniqueRecords() </code> <shameless plug> You can get adodbapi at http://sourceforge.net/projects/adodbapi/ </plug> On Fri, Oct 7, 2011 at 7:12 PM, Perez, Justin < justin.pe...@energytransfer.com> wrote: > I would like to be able to call a C# something from a python script from > IDLE or if better from ironpython. The code I need to call is below. I am > fairly certain that this is VB.net so if easiest I could build this in a > vb.net something. I do not know how to package this into something that > could be called from python (c# or vb -.net). It would be most cool if I > could call from ironpython. Thanks. > > Public Sub ListUniqueRecords() > > Dim pMyTable As ITable > Dim pCurs As ICursor = Nothing > Dim intFieldIdx As Integer > Dim pDataStatistics As IDataStatistics > Dim pEnumVar As IEnumerator > Dim pWorkspaceFactory As IWorkspaceFactory > Dim pWorkspace As IWorkspace > Dim pFeatWorkSpace As IFeatureWorkspace > Dim strMyField As String = “VAL” > > Try > pWorkspaceFactory = New AccessWorkspaceFactory > pWorkspace = > pWorkspaceFactory.OpenFromFile(“C:\MyPath\MyGDB.mdb”, 0) > pFeatWorkSpace = CType(pWorkspace, IFeatureWorkspace) > pMyTable = pFeatWorkSpace.OpenTable(“MyTableName”) > intFieldIdx = pMyTable.FindField(strMyField) > > pCurs = pMyTable.Search(Nothing, True) > pDataStatistics = New DataStatistics > pDataStatistics.Field = strMyField > pDataStatistics.Cursor = pCurs > > pEnumVar = CType(pDataStatistics.UniqueValues, IEnumerator) > > Do Until pEnumVar.MoveNext = False > Debug.Print(pEnumVar.Current.ToString) > Loop > > Catch ex As Exception > Trace.WriteLine(ex.ToString) > Finally > ‘clean up > pCurs = Nothing > pWorkspace = Nothing > End Try > > End Sub >
_______________________________________________ Ironpython-users mailing list Ironpython-users@python.org http://mail.python.org/mailman/listinfo/ironpython-users