Salakhetdinov Shamil
mcp2004 at mail.ru
Fri Mar 27 06:35:25 CDT 2009
Hi Gustav and SCRUM Team, The issue was that in app.config we have got somehow renamed Northwind.NET.FE.Properties.Settings.NorthwindNETConnectionString to NNNorthwind.NET.FE.Properties.Settings.NorthwindNETConnectionString watch two addiional letters 'NNN' added in the beginning... The fact is that when you change connection string in app.config it's OK and good enough for datasets to work/use this connection string. But it still isn't changed in application settings. If (as we have got) the connection string name is renamed in app.config then Visual Studio (e.g. when you try to preview datasets' data) uses default value from settings - and this value is hardcoded on last edit and compile of application settings (via project properties-> settings designer) etc. Visual Studio has several such "points of confusion" because it uses parts of the source project "compiled on the fly" in *design mode*: strongly typed datasets are just C# classes and when they are used in design mode they get compiled and they use settings which are loaded from app.config if corresponding app.config value is present, and it was absent in our case - hence Visual Studio used hardcoded value... Moreover in runtime {{executable file name}}.config file is used to load settings - in our case this is Northwind.NET.FE.exe.config (check \Bin folder) - this file is generated by VS on project rebuilding. (I didn't put this file under source code control as everybody gets their own vesion of this file when they recompile/rebuild solution and this happens every time you do a change to your code and then start application from within visual studion with or wothout debugging. Some more information: there are different *scopes* of settings as you can see in settings design window: - Application and User. When one will try to find how this works they usually get lost (as I do :)) - when you save User scope settings when using your app in runtime mode they *do get saved* but not in {{executable file name}}.config - they are saved somewhere on your system in your windows current user area - I still can't find where - do you? Visual Studio and .NET Framework are huge and it takes some time to get used to them - I'm working with them for fifth year and still see that there comes a lot of new stuff to learn as opposite to MS Access when I was at "guru level" in less than two years of using MS Access application in actual development - I suppose that "guru level" with .NET Framework and VS is unacheivable in one's lifetime :) - and I feel OK with that :)))... Let's discuss actively the issues as the subject one then we will proceed quicker - as I have written here several times: please questions everything you see coming from here, especially if it doesn't work as expected... (as I noted I didn't use strongly typed datastes that much with .NET and I didn't use standard handling of settings in VS because they partially are "black boxes" in some parts but for this project to avoid a lot of manual coding we'd better use these "black boxes")... Thank you. -- Shamil P.S. This is how strongly typed dataset gets connection string value from settings, and settings load that value from app.config if it's present there AFAIU or use hardcoded value if it's absent - the latter happended in our case with two additional letters 'NN' getting in front of connection string name in app.config: DataModelDataSet.Designer.cs ============================ .... [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] private void InitConnection() { this._connection = new global::System.Data.SqlClient.SqlConnection(); this._connection.ConnectionString = global::Northwind.NET.FE.Properties.Settings.Default.NorthwindNETConnectionString; } ... Settings.Designer.cs ===================== namespace Northwind.NET.FE.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); public static Settings Default { get { return defaultInstance; } } [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] [global::System.Configuration.DefaultSettingValueAttribute("Data Source=HAMBURG\\SQL2005;Initial Catalog=NorthwindNET;Integrated Security=True" + ";Language=English")] public string NorthwindNETConnectionString { get { return ((string)(this["NorthwindNETConnectionString"])); } } -----Original Message----- From: "Gustav Brock" <Gustav at cactus.dk> To: "<dba-VB" <dba-vb at databaseadvisors.com> Date: Fri, 27 Mar 2009 11:29:17 +0100 Subject: Re: [dba-VB] SCRUM Is source code control working OK for you? > Hi SCRUM Team and all > > This really caused me a headache, and even when I found out as described here that the connection string is stored in the settings too, I still couldn't open the datasets as described here: > > https://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=113567 > > However, this morning after a restart it suddenly worked. > > This issue is not common as in "real life" we all would attach to the same database, thus the issue would be moot. > > Despite all the trouble with the source code system - it took some time to get going - I like it very much including VisualSVN. It is extremely convenient to have the tiny green/yellow/red balls juxtaposed the normal icons - at a glance you can see which files have been changed. > Sometimes you need a kick to get started and I will for sure follow this route and set up my own server for new projects as I work both from home and from the office. Also, external assistance could be called easily! > > /gustav > > > >>> Salakhetdinov Shamil <mcp2004 at mail.ru> 26-03-2009 17:48 >>> > > Hi SCRUM Team and all, > > OK, this should: > > Right-Click Project name -> Properties -> Settings -> NorthwindNETConnectionString > > with setting value = > > Data Source=HAMBURG\SQL2005;Initial Catalog=NorthwindNET;Integrated Security=True > > which should be edited and then app.config's <connectionStrings> sestion is getting (re-)generated. But as far as I can see the value from app.config is not used by strongly-typed datasets - instead hardcoded value from > > Northwind.NET.FE -> Properties -> Settings.Designer.cs is used... > > We can keep replacing each other connection strings if we will be commiting > > Settings.Designer.cs and app.config - IOW better not commit them if we do not introduce new settings. > > In any event take anote that if you are getting trouble opening say CategoriesForm then you have to edit connection string in project settings not in app.config. > > Sorry for confusion I introduced. (I must say I rarely use strongly typed datasets but this issue/subject is another story we can talk in half a year probably - maybe in that time I will become adept of strongly typed datasets and ADO.NET Entity Framework and I will forget my current preferences of using custom object models with as little ADO.NET as possibel and without any strongly typed datasets at all... > > Thank you. > > -- > Shamil > > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com >