Question : ConfigurationManager returns no settings

I have a project for a DLL in a Visual Studio 2010 solution.  The project includes the System.Configuration reference and an app.Config with a connection strings section.  

1:
2:
3:
4:
5:
6:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <connectionStrings>
        <add name="MyConnectionString" 
            connectionString="Data Source=MyComputer\SQLEXPRESS;Initial Catalog=MyDb;Integrated Security=SSPI;"/>
    </connectionStrings>


The DLL builds successfully and places a DLLName.config file under the bin\Debug folder.

When I debug the code, ConfigurationManager returns a NameValueCollection with zero entries.

1:
2:
3:
   Dim appSettings As Specialized.NameValueCollection = ConfigurationManager.AppSettings
 


Also, the code below returns an empty string:

1:
2:
  connString = ConfigurationManager.AppSettings( "MyConnectionString" )


Do I need to specifically instantiate the ConfigurationManager with the full path specification of the app.Config in the project?

Answer : ConfigurationManager returns no settings

Yes, On your code when you eval CustomerId or bind this Will return a value that will be the name of the image, with the Javascript that I send you you can say that if the return is null or blank or the condition that you wnat then return the default image name if not return the value that get the customer photo.I modify the code because I made a mistake. Will be like this

<script language="vbscript" runat="server">
    Function EvalPhoto(ByVal Customer)
        Dim Cid, ReturnImg
        Cid = Customer
     'If The Customer Exist or the condition that you want
      If Cid is dbnull.value Then
            ReturnImg = Cid
        Else
            ReturnImg = "Default Image"
        End If
        Return ReturnImg
    End Function
</script>
Random Solutions  
 
programming4us programming4us