Click here to Skip to main content
11,505,486 members (64,116 online)
   

C#

 
GeneralRe: Get outlook password Pin
Sanjeev991813-Nov-12 20:49
memberSanjeev991813-Nov-12 20:49 
GeneralRe: Get outlook password Pin
n.podbielski13-Nov-12 21:04
membern.podbielski13-Nov-12 21:04 
GeneralRe: Get outlook password Pin
Pete O'Hanlon13-Nov-12 22:04
protectorPete O'Hanlon13-Nov-12 22:04 
GeneralRe: Get outlook password Pin
J4amieC13-Nov-12 22:38
memberJ4amieC13-Nov-12 22:38 
GeneralRe: Get outlook password Pin
Manfred R. Bihy13-Nov-12 22:39
mvpManfred R. Bihy13-Nov-12 22:39 
GeneralRe: Get outlook password Pin
OriginalGriff14-Nov-12 4:38
mvpOriginalGriff14-Nov-12 4:38 
GeneralRe: Get outlook password Pin
Dave Kreskowiak14-Nov-12 1:49
mvpDave Kreskowiak14-Nov-12 1:49 
GeneralRe: Get outlook password Pin
Pete O'Hanlon14-Nov-12 2:05
protectorPete O'Hanlon14-Nov-12 2:05 
GeneralRe: Get outlook password Pin
Dave Kreskowiak14-Nov-12 4:36
mvpDave Kreskowiak14-Nov-12 4:36 
AnswerRe: Get outlook password Pin
Abhinav S13-Nov-12 21:07
mvpAbhinav S13-Nov-12 21:07 
GeneralRe: Get outlook password Pin
Pete O'Hanlon13-Nov-12 22:06
protectorPete O'Hanlon13-Nov-12 22:06 
QuestionError 19 'LogManager' is an ambiguous reference between Pin
classy_dog13-Nov-12 16:09
memberclassy_dog13-Nov-12 16:09 
AnswerRe: Error 19 'LogManager' is an ambiguous reference between Pin
Dave Kreskowiak13-Nov-12 18:38
mvpDave Kreskowiak13-Nov-12 18:38 
QuestionC# use connection string in app.config Pin
rachel_m13-Nov-12 11:46
memberrachel_m13-Nov-12 11:46 
Can you tell me how to use the connection string value from the app.config file and not the hard codee values?

In a C# 2008 desktop/console application, I created the connections to the database using linq to sql. Everything worked fine until I moved the
code to point to a different database. Somehow the original database connections are being saved and the values from the app.config file
are not being used.

I tried to do what the following link: http://refat38.wordpress.com/2012/01/30/unpick-linq-to-sql-connection-string-from-application-settings/,
said to do however, I do not know what the following statement means to do from this link:
Now Right Click and open the Properties on your DAL or project containing your LINQ to SQL classes and remove the connection string “Application Setting” reference on the Settings tab.

I also tried to add the following to the *.designer.cs file:
base(ConfigurationManager.ConnectionStrings["esample.Properties.Settings.devtestConnectionString"].ConnectionString, mappingSource) and attached
a system.configuration file as a reference.

1. The following code is from the app.config file:
<connectionStrings>
    
    <add name="esample.Properties.Settings.devtestConnectionString"
      connectionString="Data Source=dev;Initial Catalog=devtest;Integrated Security=True"
      providerName="System.Data.SqlClient" />    
  </connectionStrings>
 
2. The following is from the settings.settings file
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="esample.Properties" GeneratedClassName="Settings">
  <Profiles />
  <Settings>
    <Setting Name="devtestConnectionString" Type="(Connection string)" Scope="Application">
      <DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ConnectionString>Data Source=dev;Initial Catalog=devtest;Integrated Security=True</ConnectionString>
  <ProviderName>System.Data.SqlClient</ProviderName>
</SerializableConnectionString></DesignTimeValue>
      <Value Profile="(Default)">Data Source=dev;Initial Catalog=devtest;Integrated Security=True</Value>
    </Setting>
   </Settings>
</SettingsFile>
 
The following is from the settings.designer.cs file
namespace esample.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=dev;Initial Catalog=devtest;Integrated Security=True")]
        public string devtestConnectionString {
            get {
                return ((string)(this["devtestConnectionString"]));
            }
        }
        
        
    }
}
 
The following is from the *.designer.cs
 
namespace esample
{
	using System.Data.Linq;
	using System.Data.Linq.Mapping;
	using System.Data;
	using System.Collections.Generic;
	using System.Reflection;
	using System.Linq;
	using System.Linq.Expressions;
	using System.ComponentModel;
	using System;
        using System.Configuration;
	
	
	[System.Data.Linq.Mapping.DatabaseAttribute(Name="devtest")]
	public partial class esampleDataContext : System.Data.Linq.DataContext
	{
		
		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
 
		
		public esampleDataContext() :
 
        base(global::esample.Properties.Settings.Default.devtestConnectionString, mappingSource)
        //base(ConfigurationManager.ConnectionStrings["esample.Properties.Settings.devtestConnectionString"].ConnectionString,  mappingSource)
          {	
			OnCreated();
		}
		
		public esampleDataContext(string connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
Can you show me code and/or tell me how to solve this problem so I can obtain the value from the app.config file?
AnswerRe: C# use connection string in app.config Pin
Clifford Nelson13-Nov-12 11:55
memberClifford Nelson13-Nov-12 11:55 
GeneralRe: C# use connection string in app.config Pin
rachel_m13-Nov-12 17:45
memberrachel_m13-Nov-12 17:45 
GeneralRe: C# use connection string in app.config Pin
Pete O'Hanlon13-Nov-12 19:39
protectorPete O'Hanlon13-Nov-12 19:39 
AnswerRe: C# use connection string in app.config Pin
Clifford Nelson14-Nov-12 5:08
memberClifford Nelson14-Nov-12 5:08 
AnswerRe: C# use connection string in app.config Pin
n.podbielski13-Nov-12 20:24
membern.podbielski13-Nov-12 20:24 
QuestionC# GoF Design pattern usage Pin
Gohan_Coder13-Nov-12 8:15
memberGohan_Coder13-Nov-12 8:15 
AnswerCross posted from the lounge and Q and A. Pin
Pete O'Hanlon13-Nov-12 9:13
protectorPete O'Hanlon13-Nov-12 9:13 
AnswerRe: C# GoF Design pattern usage Pin
Eddy Vluggen13-Nov-12 11:32
memberEddy Vluggen13-Nov-12 11:32 
AnswerRe: C# GoF Design pattern usage Pin
Abhinav S13-Nov-12 21:15
mvpAbhinav S13-Nov-12 21:15 
AnswerRe: C# GoF Design pattern usage Pin
Pete O'Hanlon13-Nov-12 22:28
protectorPete O'Hanlon13-Nov-12 22:28 
QuestionMethod, Class, Object Reference Pin
C-P-User-312-Nov-12 10:31
memberC-P-User-312-Nov-12 10:31 
AnswerRe: Method, Class, Object Reference Pin
Pete O'Hanlon12-Nov-12 10:49
protectorPete O'Hanlon12-Nov-12 10:49 
GeneralRe: Method, Class, Object Reference Pin
C-P-User-312-Nov-12 13:19
memberC-P-User-312-Nov-12 13:19 
GeneralRe: Method, Class, Object Reference Pin
Pete O'Hanlon12-Nov-12 20:15
protectorPete O'Hanlon12-Nov-12 20:15 
GeneralRe: Method, Class, Object Reference Pin
J4amieC12-Nov-12 21:36
memberJ4amieC12-Nov-12 21:36 
GeneralRe: Method, Class, Object Reference Pin
Pete O'Hanlon12-Nov-12 22:11
protectorPete O'Hanlon12-Nov-12 22:11 
GeneralRe: Method, Class, Object Reference Pin
Simon_Whale12-Nov-12 22:06
memberSimon_Whale12-Nov-12 22:06 
GeneralRe: Method, Class, Object Reference Pin
Marcus Kramer13-Nov-12 3:49
memberMarcus Kramer13-Nov-12 3:49 
GeneralRe: Method, Class, Object Reference Pin
C-P-User-313-Nov-12 8:06
memberC-P-User-313-Nov-12 8:06 
QuestionAdd a Menu Item to the operating system contextmenu Pin
benzarabel12-Nov-12 9:48
memberbenzarabel12-Nov-12 9:48 
AnswerRe: Add a Menu Item to the operating system contextmenu Pin
Eddy Vluggen12-Nov-12 10:44
memberEddy Vluggen12-Nov-12 10:44 
GeneralRe: Add a Menu Item to the operating system contextmenu Pin
benzarabel12-Nov-12 10:51
memberbenzarabel12-Nov-12 10:51 
GeneralRe: Add a Menu Item to the operating system contextmenu Pin
Eddy Vluggen12-Nov-12 11:18
memberEddy Vluggen12-Nov-12 11:18 
QuestionTips for a new C# designer... Pin
Maurice Lantier12-Nov-12 9:28
memberMaurice Lantier12-Nov-12 9:28 
AnswerRe: Tips for a new C# designer... Pin
Eddy Vluggen12-Nov-12 10:40
memberEddy Vluggen12-Nov-12 10:40 
GeneralRe: Tips for a new C# designer... Pin
Maurice Lantier12-Nov-12 10:54
memberMaurice Lantier12-Nov-12 10:54 
GeneralRe: Tips for a new C# designer... Pin
Eddy Vluggen12-Nov-12 11:18
memberEddy Vluggen12-Nov-12 11:18 
AnswerRe: Tips for a new C# designer... Pin
BobJanova12-Nov-12 22:23
memberBobJanova12-Nov-12 22:23 
GeneralRe: Tips for a new C# designer... Pin
Maurice Lantier14-Nov-12 10:19
memberMaurice Lantier14-Nov-12 10:19 
AnswerRe: Tips for a new C# designer... Pin
S Godrich12-Nov-12 23:48
memberS Godrich12-Nov-12 23:48 
GeneralRe: Tips for a new C# designer... Pin
Maurice Lantier14-Nov-12 10:15
memberMaurice Lantier14-Nov-12 10:15 
Questionwindows form design Pin
Rajeevhyd12-Nov-12 7:09
memberRajeevhyd12-Nov-12 7:09 
AnswerRe: windows form design Pin
Eddy Vluggen12-Nov-12 10:34
memberEddy Vluggen12-Nov-12 10:34 
GeneralNamed Pipes app lifetime pipe. Pin
Nemo196612-Nov-12 6:51
memberNemo196612-Nov-12 6:51 
GeneralRe: Named Pipes app lifetime pipe. Pin
Dave Kreskowiak12-Nov-12 7:23
mvpDave Kreskowiak12-Nov-12 7:23 
GeneralRe: Named Pipes app lifetime pipe. Pin
Nemo196612-Nov-12 9:10
memberNemo196612-Nov-12 9:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 3 Jun 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid