Click here to Skip to main content
15,896,269 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionA simple closing port question Pin
Draqonis28-Mar-07 10:04
Draqonis28-Mar-07 10:04 
Questionexporting a crystal report in to Excel format Pin
indian14327-Mar-07 21:25
indian14327-Mar-07 21:25 
AnswerRe: exporting a crystal report in to Excel format Pin
Pete O'Hanlon27-Mar-07 23:47
mvePete O'Hanlon27-Mar-07 23:47 
GeneralRe: exporting a crystal report in to Excel format Pin
indian14328-Mar-07 2:29
indian14328-Mar-07 2:29 
QuestionTimers Pin
Jim Warburton27-Mar-07 7:27
Jim Warburton27-Mar-07 7:27 
AnswerRe: Timers Pin
Dave Kreskowiak27-Mar-07 7:48
mveDave Kreskowiak27-Mar-07 7:48 
GeneralRe: Timers Pin
Jim Warburton27-Mar-07 8:03
Jim Warburton27-Mar-07 8:03 
QuestionGetting two connection string from .config file instead of one?! Pin
Oshtri Deka27-Mar-07 3:54
professionalOshtri Deka27-Mar-07 3:54 
I have made small testing app. Iniatialy I have used database connection via IDE (Data Sources -> Add New Data Source), later I have shifted my project to another PC so I had to change Data source.
I have removed old data source from IDE, attached database to another server and stored connectiong string in App.config file.
BUT when I tried to reach this information first time I found out there were more than one conn string!
Old one (which was never in App.config!) and new one.
My confusion was even greater because I haven't had .config file (nor -.settings) prior the change of data source.
Where is old connection string stored? It's not in App.config!

I made ad hoc solution for the moment, method shown passes first usable connection string:

<br />
        //Connection check<br />
        public static bool ProvjeriKonekciju()<br />
        {<br />
            bool povrat = false;<br />
            SqlConnection conn = null;<br />
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);<br />
            ConnectionStringsSection section = config.ConnectionStrings;<br />
            ConnectionStringSettings settings;<br />
<br />
            for (int i = 0; i < section.ConnectionStrings.Count; i++)<br />
            {<br />
                settings = section.ConnectionStrings[i];<br />
                if (settings == null) continue;<br />
<br />
                conn = new SqlConnection(settings.ConnectionString);<br />
                try<br />
                {<br />
                    conn.Open();<br />
                    if (conn.State == ConnectionState.Open)<br />
                    {<br />
                        povrat = true;<br />
                        //global variable<br />
                        _ConnString = settings.ConnectionString;<br />
                        povrat = true;<br />
                        break;<br />
                    }<br />
                }<br />
                catch (SqlException sqlex)<br />
                {<br />
                    Debug.WriteLine(sqlex.ToString());<br />
                }<br />
                catch (Exception ex)<br />
                {<br />
                    Debug.WriteLine(ex.ToString());<br />
                }finally<br />
                {<br />
                    conn.Dispose();<br />
                }<br />
            }<br />
            return povrat;<br />
        }


How can I eliminate the intruder?
I'm using Visaul C# 2005 Express.
Help.

I'm not native English speaker, so excuse me.
Feel free to point out bad code aswell.
AnswerRe: Getting two connection string from .config file instead of one?! Pin
Oshtri Deka28-Mar-07 0:12
professionalOshtri Deka28-Mar-07 0:12 
AnswerRe: Getting two connection string from .config file instead of one?! Pin
kubben28-Mar-07 1:36
kubben28-Mar-07 1:36 
GeneralRe: Getting two connection string from .config file instead of one?! Pin
Oshtri Deka28-Mar-07 22:53
professionalOshtri Deka28-Mar-07 22:53 
QuestionPls. how can I avoid these exceptions Pin
indian14327-Mar-07 0:27
indian14327-Mar-07 0:27 
AnswerRe: Pls. how can I avoid these exceptions Pin
__DanC__27-Mar-07 0:43
__DanC__27-Mar-07 0:43 
GeneralRe: Pls. how can I avoid these exceptions Pin
indian14327-Mar-07 1:00
indian14327-Mar-07 1:00 
GeneralRe: Pls. how can I avoid these exceptions Pin
Christian Graus27-Mar-07 2:45
protectorChristian Graus27-Mar-07 2:45 
GeneralRe: Pls. how can I avoid these exceptions Pin
Colin Angus Mackay28-Mar-07 0:55
Colin Angus Mackay28-Mar-07 0:55 
AnswerRe: Pls. how can I avoid these exceptions Pin
Scott Dorman27-Mar-07 19:06
professionalScott Dorman27-Mar-07 19:06 
AnswerRe: Pls. how can I avoid these exceptions Pin
Brady Kelly27-Mar-07 19:47
Brady Kelly27-Mar-07 19:47 
QuestionWindows service load sequence question.... Pin
Draqonis26-Mar-07 11:18
Draqonis26-Mar-07 11:18 
AnswerRe: Windows service load sequence question.... Pin
kubben27-Mar-07 3:13
kubben27-Mar-07 3:13 
QuestionMozilla FireFox Support in .NET Framework 2.0 Config Pin
Vasudevan Deepak Kumar26-Mar-07 11:06
Vasudevan Deepak Kumar26-Mar-07 11:06 
QuestionClosing tcp port on Dual 2 Core processor Pin
Draqonis26-Mar-07 5:22
Draqonis26-Mar-07 5:22 
QuestionMSI Programming Pin
tonyalex26-Mar-07 4:46
tonyalex26-Mar-07 4:46 
AnswerRe: MSI Programming Pin
Vasudevan Deepak Kumar28-Mar-07 7:48
Vasudevan Deepak Kumar28-Mar-07 7:48 
QuestionRaising an event from a composite control Pin
Richard Jones26-Mar-07 4:28
Richard Jones26-Mar-07 4:28 

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

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