Reputation: 3443
I am maintaining a site that was not built by me in ASP.NET.
it is built in C#.NET
the site access a Database using a DLL called MegaTecDAL.dll
(Note: i dont have the code for this dll, only the dll and PDB)
Recently, we need to move the site to another server with another database, and therefore need to change the connection string for the database.
which i thought should be pretty Easy!
i didn't find the connection string in the web.config or anywhere so,
I decompiled the Data Access Layer MegaTecDAL.DLL to get where the connection string is read from, and found the following (Notice: getzConnectionString)
namespace MegaTecDal.Properties
{
[CompilerGenerated]
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed class Settings : ApplicationSettingsBase
{
private static Settings defaultInstance = (Settings) SettingsBase.Synchronized((SettingsBase) new Settings());
public static Settings Default
{
get
{
Settings settings = Settings.defaultInstance;
return settings;
}
}
[DefaultSettingValue("Data Source=old.server.address.com;Initial Catalog=getz;User ID=aUserName;Password=StrongPassword")]
[ApplicationScopedSetting]
[SpecialSetting(SpecialSetting.ConnectionString)]
[DebuggerNonUserCode]
public string getzConnectionString
{
get
{
return (string) this["getzConnectionString"];
}
}
static Settings()
{
}
}
}
I Realize, that the connection string is taken from the Default.
but i cant seem to find how to specify a new Value.
I Tried:
adding to the web.config
<connectionStrings>
<add name="getzConnectionString" connectionString="Data Source=new.server.com;Initial Catalog=getz;User ID=aUserName;Password=StrongPassword" providerName="System.Data.SqlClient" />
</connectionStrings>
also tried adding to web.config
<appSettings>
<add key="getzConnectionString" value="Data Source=new.server.com;Initial Catalog=getz;User ID=aUserName;Password=StrongPassword"/>
</appSettings>
tried creating a file named MegaTecDAL.dll.config
with the above sections and put it in the BIN/App_Data/App_Code & root folders but still, default connection string is called.
also tried adding Section group and section per http://msdn.microsoft.com/en-us/library/8eyb2ct1.aspx
Anywhere i put it it does not do it.
Upvotes: 2
Views: 1133
Reputation: 6590
<connectionStrings>
<add
name="getzConnectionString"
connectionString="Data Source=serverName;Initial
Catalog=getz;Persist Security Info=True;User
ID=userName;Password=password"
providerName="System.Data.SqlClient"/>
</connectionStrings>
This might helps you. Try to add this. for more details check this link http://msdn.microsoft.com/en-us/library/ms178411%28v=vs.100%29.aspx
Upvotes: 0
Reputation: 9249
I think you need to include the namespace of the ConnectionString you want to configure:
<connectionStrings>
<add name="MegaTecDal.Properties.Settings.getzConnectionString"
connectionString="yourNewConnectionString"
providerName="System.Data.SqlClient" />
</connectionStrings>
Upvotes: 4