<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Create ArcSDE Connection File - Use Feature Class? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/create-arcsde-connection-file-use-feature-class/m-p/133750#M4590</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to add a feature class from our database to the FlexViewer application, usually this isn't a problem because all our users connect to the database with a read only password, I would just add the feature class via a reaad only connection to the MXD and publish as a service.&amp;nbsp; However, this database restricts access as to what can be read, each user can see different feature in the feature class.&amp;nbsp; So I thought I would publish a geoporcessing model that prompts the user for their username and password, and expose the model via the GP widget for the flex viewer.&amp;nbsp; At the moment, I am stuck creating the model.&amp;nbsp; I can make the connection file, but I can't seem to reference feature classes that exist within the database?&amp;nbsp; The model remains white.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;How do I use the result of the 'Create ArcSDE Connection File' tool in model builder to work with a feature class contained within the database I'm conencting to?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've exported the model as python, but it looks ok to me, am I missing something obvious?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
# Set the necessary product code
import arceditor


# Import arcpy module
import arcpy

# Script arguments
Username = arcpy.GetParameterAsText(0)

Password = arcpy.GetParameterAsText(1)

# Local variables:
Test_sde = Username
Connections = "\\\\myserver.com\\somewhere\\Scripts\\Connections"
PROSPECTS_GIS = "PROSPECTS_GIS"
Output = "%ScratchWorkspace%\\Output"

# Process: Create ArcSDE Connection File
arcpy.CreateArcSDEConnectionFile_management(Connections, "Test", "DBSERVER.COM", "4150", "DB", "DATABASE_AUTH", Username, Password, "SAVE_USERNAME", "sde.DEFAULT", "SAVE_VERSION")

# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(PROSPECTS_GIS, Output, "", "", "")
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Dec 2011 08:39:48 GMT</pubDate>
    <dc:creator>RobDunfey</dc:creator>
    <dc:date>2011-12-01T08:39:48Z</dc:date>
    <item>
      <title>Create ArcSDE Connection File - Use Feature Class?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/create-arcsde-connection-file-use-feature-class/m-p/133750#M4590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to add a feature class from our database to the FlexViewer application, usually this isn't a problem because all our users connect to the database with a read only password, I would just add the feature class via a reaad only connection to the MXD and publish as a service.&amp;nbsp; However, this database restricts access as to what can be read, each user can see different feature in the feature class.&amp;nbsp; So I thought I would publish a geoporcessing model that prompts the user for their username and password, and expose the model via the GP widget for the flex viewer.&amp;nbsp; At the moment, I am stuck creating the model.&amp;nbsp; I can make the connection file, but I can't seem to reference feature classes that exist within the database?&amp;nbsp; The model remains white.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;How do I use the result of the 'Create ArcSDE Connection File' tool in model builder to work with a feature class contained within the database I'm conencting to?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've exported the model as python, but it looks ok to me, am I missing something obvious?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
# Set the necessary product code
import arceditor


# Import arcpy module
import arcpy

# Script arguments
Username = arcpy.GetParameterAsText(0)

Password = arcpy.GetParameterAsText(1)

# Local variables:
Test_sde = Username
Connections = "\\\\myserver.com\\somewhere\\Scripts\\Connections"
PROSPECTS_GIS = "PROSPECTS_GIS"
Output = "%ScratchWorkspace%\\Output"

# Process: Create ArcSDE Connection File
arcpy.CreateArcSDEConnectionFile_management(Connections, "Test", "DBSERVER.COM", "4150", "DB", "DATABASE_AUTH", Username, Password, "SAVE_USERNAME", "sde.DEFAULT", "SAVE_VERSION")

# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(PROSPECTS_GIS, Output, "", "", "")
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Dec 2011 08:39:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/create-arcsde-connection-file-use-feature-class/m-p/133750#M4590</guid>
      <dc:creator>RobDunfey</dc:creator>
      <dc:date>2011-12-01T08:39:48Z</dc:date>
    </item>
  </channel>
</rss>

