Hi, I wrote a script that updates a feature class from SQL server. It is exactly the same script as http://forums.arcgis.com/threads/45954-Can-t-view-created-feature-class except I am connecting to a different database, and the template FC is different. I noticed when I include field names longer then 10 characters, the code chokes And I get the "File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\_base.py", line 35, in __setattr__ return setattr(self._arc_object, attr, ao)RuntimeError: ERROR 999999: Error executing function." error.I can't figure out the problem especially since the previosu code also contained feature names > 10 characters.Does anyone have a suggestion about this?THanks, BArt import arcpy
import pyodbc
from arcpy import env
cnxn = pyodbc.connect('Driver={SQL Server Native Client 10.0};UID=user;PWD=Password;SERVER=spk-db11sac.spk.ds.usace.army.mil; DATABASE=FTO_OE; APP=MyApp')
cursor=cnxn.cursor()
cursor.execute("select Grid_ID, UniqueID, Date_Found, Quantity, Northing, Easting, Depth, Grid_Alias, AAR_ID, Initial_ID, Final_ID, Risk_Code, MM_Type, Contractor, Burial_Pit, Weight from dbo.View_MEC_FeatureClass") #,Report_Type, Operation_Class,Operation_ID, Report_Date, AAR_Description, Original_MM_Nomenclature, Model_Description, Survey_Instrument, Modification_Notes,")
rows = cursor.fetchall()
env.overwriteOutput = True
env.workspace = r"G:\Temp\Bart\fort_ord.gdb"
template = r"G:\Fort_Ord_GIS\Master_Coverage\Fort_Ord.gdb\env_haz_remediation\oe_item_point"
config_keyword = ""
OETabl = arcpy.CreateTable_management(r"G:\Temp\Bart", "OETabl.dbf", template)
Wcur = arcpy.InsertCursor(OETabl)
for row in rows:
t_row = Wcur.newRow()
t_row.UniqueID = row.UniqueID
t_row.Date_Found = row.Date_Found
#t_row.Operation_Class = row.Operation_Class !!!GET ERROR MESSAGE ON COMMENTED OUT LINES!!!
#t_row.Operation_ID = row.Operation_ID
t_row.Grid_ID = row.Grid_ID
t_row.AAR_ID = row.AAR_ID
t_row.Report_Type = row.Report_Type
#t_row.Report_Date = row.Report_Date
#t_row.AAR_Description = row.AAR_Description
t_row.Northing = row.Northing
t_row.Easting = row.Easting
t_row.Quantity = row.Quantity
t_row.Depth = row.Depth
t_row.Weight = row.Weight
t_row.Initial_ID = row.Initial_ID
t_row.Final_ID = row.Final_ID
#t_row.Model_Description = row.Model_Description
t_row.Risk_Code = row.Risk_Code
t_row.MM_Type = row.MM_Type
t_row.Contractor = row.Contractor
t_row.Burial_Pit = row.Burial_Pit
#t_row.Survey_Instrument = row.Survey_Instrument
#t_row.Modification_Notes = row.Modification_Notes
#t_row.Original_MM_Nomenclature = row.Original_MM_Nomenclature
Wcur.insertRow(t_row)
try:
in_Table = OETabl
x_coords = "Easting"
y_coords = "Northing"
out_layer = "OE_layer"
saved_layer = r"G:\Temp\Bart\Layers\OE.lyr"
spRef = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Projected Coordinate Systems\State Plane\NAD 1983 (US Feet)\NAD 1983 StatePlane California IV FIPS 0404 (US Feet).prj"
arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_layer, spRef)
saved_layer2 = arcpy.SaveToLayerFile_management(out_layer, saved_layer)
except:
print arcpy.GetMessages()
inFeatures = saved_layer2
outLocation = r"G:\Temp\Bart\Scratch.gdb"
outFeatureClass = "OEupdate"
outFC = outLocation + "\\" + outFeatureClass
if arcpy.Exists(outFC)==True:
arcpy.Delete_management(outFC)
arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outLocation, outFeatureClass)
cnxn.commit()
cursor.close()
cnxn.close()
del row
del rows
del cursor
del cnxn