Hello,
I wrote a python code to AddJoin a personal geodatabases (zlm-07.31.mdb) containing 23 featureclasses to a table view (fcode) for every featureclass .They have a field in common (DB).when I run the code in a featureclass, it works well . running the code below.
However,when running code loop through among 23 featureclasses, the error message is
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000728: Field DB does not exist within table
Failed to execute (AddJoin).
Please kindly advise how to modify the code.
Thank you.
running the code below.
I wrote a python code to AddJoin a personal geodatabases (zlm-07.31.mdb) containing 23 featureclasses to a table view (fcode) for every featureclass .They have a field in common (DB).when I run the code in a featureclass, it works well . running the code below.
Code:
#!/usr/bin/python
# -*- coding: GB2312 -*-
# Import system modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = 1
# Set workspace to folder containing personal geodatabases
#
gp.Workspace = r"F:\ysss" #sys.argv[1] #
fcode = "F:\\ysss\\zlm-07.31.mdb\\fcode" # sys.argv[2]
# Identify personal geodatabases
#
pgdbs = gp.ListWorkspaces("","Access")
for pgdb in pgdbs:
# Set workspace to current personal geodatabase
#
gp.workspace = pgdb
datasets = gp.listdatasets()
for ds in datasets:
gp.Workspace = ds
fcs = gp.ListFeatureClasses()
for fc in fcs:
if str(fc)=="HYDPY":
Output_Layer =""
# Local variables...
#RESPY = "F:\\ysss\\zlm-07.31.mdb\\sx500\\HYDLN"
#RESPY__3_ = "F:\\ysss\\zlm-07.31.mdb\\sx500\\HYDLN"
Output_Layer = fc+"_Layer"
# fcode = "F:\\ysss\\zlm-07.31.mdb\\fcode"
#ttt = "HYDLN_Layer"
# RESPY_Layer = "HYDLN_Layer"
#Output_Layer_Name = "HYDLN_Layer"
#fc = "HYDLN"
# Process: Add Field...
gp.AddField_management(fc, "name278", "TEXT")
# Process: Make Feature Layer...
gp.MakeFeatureLayer_management(fc, Output_Layer)
# Process: Add Join...
gp.AddJoin_management(Output_Layer, "DB", fcode, "DB", "KEEP_ALL")
# Process: Calculate Field...
gp.CalculateField_management(Output_Layer, fc+ ".name278", "[fcode.名称]", "VB", "")
# Process: Remove Join...
gp.RemoveJoin_management(Output_Layer, "fcode")
print gp.GetMessages()
gp.AddMessage(gp.GetMessages())ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000728: Field DB does not exist within table
Failed to execute (AddJoin).
Please kindly advise how to modify the code.
Thank you.
running the code below.
Code:
#!/usr/bin/python
# -*- coding: GB2312 -*-
# Import system modules
import sys, string, os, arcgisscripting
# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)
gp.OverWriteOutput = 1
# Set workspace to folder containing personal geodatabases
#
gp.Workspace = r"F:\ysss" #sys.argv[1] #
fcode = "F:\\ysss\\zlm-07.31.mdb\\fcode" # sys.argv[2]
# Identify personal geodatabases
#
pgdbs = gp.ListWorkspaces("","Access")
for pgdb in pgdbs:
# Set workspace to current personal geodatabase
#
gp.workspace = pgdb
datasets = gp.listdatasets()
for ds in datasets:
gp.Workspace = ds
fcs = gp.ListFeatureClasses()
for fc in fcs:
#if str(fc)=="HYDPY":
Output_Layer =""
# Local variables...
#RESPY = "F:\\ysss\\zlm-07.31.mdb\\sx500\\HYDLN"
#RESPY__3_ = "F:\\ysss\\zlm-07.31.mdb\\sx500\\HYDLN"
Output_Layer = fc+"_Layer"
# fcode = "F:\\ysss\\zlm-07.31.mdb\\fcode"
#ttt = "HYDLN_Layer"
# RESPY_Layer = "HYDLN_Layer"
#Output_Layer_Name = "HYDLN_Layer"
#fc = "HYDLN"
# Process: Add Field...
gp.AddField_management(fc, "name278", "TEXT")
# Process: Make Feature Layer...
gp.MakeFeatureLayer_management(fc, Output_Layer)
# Process: Add Join...
gp.AddJoin_management(Output_Layer, "DB", fcode, "DB", "KEEP_ALL")
# Process: Calculate Field...
gp.CalculateField_management(Output_Layer, fc+ ".name278", "[fcode.名称]", "VB", "")
# Process: Remove Join...
gp.RemoveJoin_management(Output_Layer, "fcode")
print gp.GetMessages()
gp.AddMessage(gp.GetMessages())