dicky1980

replacedata source error

Discussion created by dicky1980 on Mar 5, 2012
Latest reply on Mar 6, 2012 by jbarrette-esristaff
Hi,
I'm trying to update the data source of a layer in a mcd using arcpy, i can get this to work when updating to a fgb but not to SDE, is there an obvious error in the oce

import arcpy
mxd = arcpy.mapping.MapDocument(r"H:\MyDocuments\ArcGIS\Untitled.mxd")
sdepath = r"Z:\webapp\mapservices\Maps\connection-files\DEV\GISCO-DEV-direct-gisco.sde"
for lyr in arcpy.mapping.ListBrokenDataSources(mxd):
    if lyr.supports("DATASOURCE"):
        if lyr.dataSource == r"H:\MyDocuments\ArcGIS\Default.gdb\Export_Output":
            lyr.replaceDataSource(sdepath, "SDE_WORKSPACE", r"GISCOVIEW.STAT_LIFEXF_NUTS2_2006_8_01M")
            lyr.name = "LifeEX"
mxd.saveACopy(r"H:\MyDocuments\ArcGIS\Untitled1.mxd")

The error is Runtime error <type 'exceptions.ValueError'>: Layer: Unexpected error

Thanks

Outcomes