on 06-15-2006 4:46 PM
Hello,
I am unable to retrieve the connection string from app.Config file using ConfigDestination in .Net Connector 2.x
The following is the snap shot of app.config file portion
<appSettings>
<add key="DestinationName" value = "ASHOST=xxx.xx.x.xxx SYSNR=0 CLIENT=100 USER=UID PASSWD=PWD" />
</appSettings>
And I am trying to extract this with the follwoing c# code
sapLogonDestination1 = new ConfigDestination ("DestinationName");
_proxy.Connection = new SAP.Connector.SAPConnection(sapLogonDestination1);
But unfortunately this piece of code is not working the way it should
Thanks all in advance
You mean, that we can't do something like:
1. Add "using System.Configuration;" to the using statement area.
2. Use "string ConnectionString = ConfigurationSettings.AppSettings["ConnectionString"].ToString();"
where "ConnectionString" is a key in the <appSettings> area in the app.config file?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> 1. Add "using System.Configuration;" to the using
> statement area.
>
> 2. Use "string ConnectionString =
> ConfigurationSettings.AppSettings["ConnectionString"].
> ToString();"
>
> where "ConnectionString" is a key in the
> <appSettings> area in the app.config file?
Of cause this is also an option, but this is not what I meant. I meant the usage of Destination and ConfigDestination in conjunction with ASPX/ASMX/Windows Forms/Component Designers.
If you drag a "Destination" from the "SAP Proxy" toolbox to one designer an maintain settings like Username or AppServerHost, they would normally go into code. Each property can be marked as a so-called "Dynamic Property". The property is maked with a little blue icon in the property window and the value is automatically written to appSettingse, e.g.
<appSettings>
<!-- Example: <add key="settingName" value="settingValue"/> -->
<add key="destination1.AppServerHost" value="host" />
<add key="destination1.Client" value="0" />
</appSettings>
Some important properties are automatically marked so, but you can freely change it.
The ConfigDestination behaves similar, but has an easier to maintain schema. Just drop a ConfigDestination from the toolbox to a designer and configure it in the properties window. You will automatically find the correct entries in the config file.
The ConfigDestiantion has an own schema to store its data. It doesn't use appSettings. Please see online documentation for class "Config" for details (ms-help://MS.VSCC.2003/SAP.NCO/NCOV2Docu/reference/SAP.Connector.Config.html).
If you want to have the settings in appSettings, use a standard "Destination" instance in conjunction with Visual Studio's "Dynamic Properties" feature.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.