Hi,
I am running the python script listed at the bottom of this message to update the data source of many layers included in one of my .mxd's.
Although the script loops though all layers in the map, the data source is only updated in the first 37 layers of more than 350 in the map.
All layers I am trying to point to are stored in SDE in a single SQL Server 2005 database.
After running the Pyhton script in ArcMap, I intermittently get an error message for my SDE connection saying that "Maximum number of connections to instance exceeded". Perhaps the "lyr.replaceDataSource " method tries to connect multiple times to SDE and runs out of connections.
Any assistance would be greatly appreciated.
Best regards
Roberto
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.isFeatureLayer:
wrkspcpath = r"C:\Documents and Settings\rfiguero\Application Data\ESRI\Desktop10.0\ArcCatalog\cmtni_emili_sde_SYSTEST.sde"
old_dataname = lyr.datasetName
new_dataname = old_dataname + '_1'
lyr.replaceDataSource (wrkspcpath, "SDE_WORKSPACE", new_dataname)
print wrkspcpath, new_dataname