Method Exportsde debugging is not a problem in VS, reporting errors after publishing to IIS: A call to a COM component returned an error HRESULT e_fail.
Google found that the solution to the problem is the same, no one works.
Later, I searched for a problem at http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=69628, and then I tried to create a temporary connection file to resolve it.
Here is the error code:
protected void Page_Load (object sender, EventArgs e)
{
EXPORTSDE (@ "Database connections/connection to Win-5b53i9jiqq5.sde/sde.) Sde.sss120038njs ", @" d:/dem/sss120038njs.img ");
}
<summary>
Exporting the IMG grid data from the ARCSDE database
</summary>
<param name= "strinrasetername" >ARCSDE database target data file </param>
<param name= "Stroutrasterpath" > Server-Exported full path </param>
public static void Exportsde (String strinrasetername, String stroutrasterpath)
{
Try
{
License initialization, if not initialized, open error
Iaoinitialize m_aoinitialize = new Aoinitialize ();
M_aoinitialize.initialize (Esrilicenseproductcode.esrilicenseproductcodeengine);
Ivariantarray parameters = new Vararrayclass ();
Set In_raster.
Parameters. ADD (Strinrasetername);
Set Out_rasterdataset.
Parameters. ADD (Stroutrasterpath);
Set geoprocessor for execution.
Geoprocessor geoprocessor = new Geoprocessor ();
Geoprocessor. Overwriteoutput = true;
Geoprocessor. Execute ("Copyraster", parameters, NULL);
}
catch (Exception ex)
{
Throw ex;
}
}
Here is the modified code (don't forget to add permissions to the appropriate folder):
protected void Button1_Click (object sender, EventArgs e)
{
String strtemppath = @ "D:/dem";//d:/dem to a downloaded path in the project
String strtempname = @ "TEMP.SDE";//temporary file name of connection SDE database
String Strallpath = Strtemppath + "//" + strtempname;//The full path of the temporary files stored in the SDE database
if (file.exists (Strallpath))
{
File.delete (Strallpath);
}
Iworkspacefactory m_pworkspacefactory =new sdeworkspacefactoryclass ();
Iworkspacename WSN = m_pworkspacefactory.create (Strtemppath, Strtempname, Connectsde (True), 0)//First create a SDE link file
EXPORTSDE (Strallpath + @ "/SDE. Sde. N120038njs6 ", @" d:/dem/sss120038njs.img ");
Response.Write ("OK");
}
<summary>
Set SDE Connection Properties
</summary>
<param name= "Chksdelinkmodle" ></param>
<returns>IPropertySet</returns>
public static Ipropertyset CONNECTSDE (bool chksdelinkmodle)
{
Define a property
Ipropertyset Propset = new Propertysetclass ();
if (Chksdelinkmodle = = true)//SDE Connection
{
Set Database server name
Propset.setproperty ("SERVER", "ggg-927bcae0082");
Sets the port for SDE, which is specified at installation time, "port:5151" when installed by default
Propset.setproperty ("INSTANCE", "port:5151");
User name for SDE
Propset.setproperty ("USER", "SDE");
Password
Propset.setproperty ("PASSWORD", "SDE");
Set the name of the database, only the SQL Server Informix database needs to be set
Propset.setproperty ("DATABASE", "SDE");
SDE version, in this for the default version
Propset.setproperty ("VERSION", "SDE.") DEFAULT ");
}
else//Direct connection
{
Set the database server name, if this machine can use "Sde:sqlserver:.", direct connection will pop up the Select Database dialog box, ask to fill in the username password
Propset.setproperty ("INSTANCE", "sde:sqlserver:xxsde");
}
return propset;
}