Click here to Skip to main content
15,908,013 members
Home / Discussions / C#
   

C#

 
AnswerRe: Call .Net 2005 DLL in .Net 2003 Pin
originSH23-Jul-07 12:06
originSH23-Jul-07 12:06 
GeneralRe: Call .Net 2005 DLL in .Net 2003 Pin
Bhavik Solanki23-Jul-07 12:20
Bhavik Solanki23-Jul-07 12:20 
GeneralRe: Call .Net 2005 DLL in .Net 2003 Pin
Paul Conrad23-Jul-07 15:14
professionalPaul Conrad23-Jul-07 15:14 
AnswerRe: Call .Net 2005 DLL in .Net 2003 Pin
Scott Dorman23-Jul-07 14:17
professionalScott Dorman23-Jul-07 14:17 
AnswerRe: Call .Net 2005 DLL in .Net 2003 Pin
Bhavik Solanki23-Jul-07 14:39
Bhavik Solanki23-Jul-07 14:39 
AnswerRe: Call .Net 2005 DLL in .Net 2003 Pin
originSH23-Jul-07 22:18
originSH23-Jul-07 22:18 
GeneralRe: Call .Net 2005 DLL in .Net 2003 Pin
Bhavik Solanki24-Jul-07 12:22
Bhavik Solanki24-Jul-07 12:22 
QuestionC# choosing database connection Pin
lino_i23-Jul-07 8:47
lino_i23-Jul-07 8:47 
I have a GUI utility and it connects to a sql server 2005 database. All of the connection code has been generated by the IDE.

I have 2 databases one for produciton and one for development. How can I switch the connection string? I am currently doing it in the Settings.Designer.cs file and checking for

#if DEBUG
//use the dev server
#else
//use the prod server
#endif

however everytime i alter the settings.settings file the IDE rewrites the Settings.Designer.cs file.

this is how the code currently works:

currently when i start my application the connection string is initialized like this:
this is called:
internal System.Data.SqlClient.SqlConnection Connection {
get {
if ((this._connection == null)) {
this.InitConnection();
}
return this._connection;
}
which calls this:
private void InitConnection() {
this._connection = new System.Data.SqlClient.SqlConnection();
this._connection.ConnectionString = global::DGView2.Properties.Settings.Default.ProdConnectionString;
}
which calls this:
public string ProdConnectionString {
get {
return ((string)(this["ProdConnectionString "]));
}
}

app.config file:

<connectionStrings>
<add name="DGView2.Properties.Settings.ProdConnectionString"
connectionString="Data Source=localhost;Initial Catalog=MyDatabase;Integrated Security=True"
providerName="System.Data.SqlClient"
<add name="DGView2.Properties.Settings.DevConnectionString" connectionString="Data Source=localhost\DEV;Initial Catalog=MyDatabase;Integrated Security=True" />

</connectionStrings>

I guess part of the problem is that this line of code:


this._connection.ConnectionString = global::DGView2.Properties.Settings.Default.ProdConnectionString;

is always calling: public string ProdConnectionString

so in my Settings.Designer.cs file I have set it up this way:

public string ProdConnectionString {
#if DEBUG
get { return ((string)(this["DevConnectionString"]));}
#else
get { return ((string)(this["ProdConnectionString"]));}
#endif
}

I am not convinced that this is the best way to do it. The ideal situation I think would be to use the desired property based on DEBUG or RELEASE in the call to the connection string:

#if DEBUG
this._connection.ConnectionString = global::DGView2.Properties.Settings.Default.DevConnectionString;
#else
this._connection.ConnectionString = global::DGView2.Properties.Settings.Default.ProdConnectionString;

#endif

however there are just to many instances of this therefore making it less efficient.

any suggestions?

thx










AnswerRe: C# choosing database connection Pin
Paul Conrad23-Jul-07 8:51
professionalPaul Conrad23-Jul-07 8:51 
GeneralRe: C# choosing database connection Pin
lino_i23-Jul-07 9:09
lino_i23-Jul-07 9:09 
AnswerRe: C# choosing database connection Pin
Pete O'Hanlon23-Jul-07 9:29
mvePete O'Hanlon23-Jul-07 9:29 
AnswerRe: C# choosing database connection Pin
Vikram A Punathambekar23-Jul-07 17:10
Vikram A Punathambekar23-Jul-07 17:10 
GeneralRe: C# choosing database connection Pin
lino_i24-Jul-07 1:49
lino_i24-Jul-07 1:49 
QuestionSimple forums question Pin
Raymond_P*23-Jul-07 7:43
Raymond_P*23-Jul-07 7:43 
AnswerRe: Simple forums question Pin
Paul Conrad23-Jul-07 8:31
professionalPaul Conrad23-Jul-07 8:31 
GeneralRe: Simple forums question Pin
Raymond_P*23-Jul-07 8:51
Raymond_P*23-Jul-07 8:51 
GeneralRe: Simple forums question Pin
Paul Conrad23-Jul-07 17:56
professionalPaul Conrad23-Jul-07 17:56 
QuestionGet FTP Root/Home directory Pin
Muhammad Nauman Yousuf23-Jul-07 7:38
Muhammad Nauman Yousuf23-Jul-07 7:38 
QuestionIIS 7.0 Pin
kibromg23-Jul-07 6:32
kibromg23-Jul-07 6:32 
AnswerRe: IIS 7.0 Pin
Paul Conrad23-Jul-07 7:51
professionalPaul Conrad23-Jul-07 7:51 
AnswerBad user! Pin
leckey23-Jul-07 8:24
leckey23-Jul-07 8:24 
JokeRe: Bad user! Pin
Paul Conrad23-Jul-07 8:29
professionalPaul Conrad23-Jul-07 8:29 
QuestionModule handling..... Pin
Arish rivlin23-Jul-07 5:59
Arish rivlin23-Jul-07 5:59 
AnswerRe: Module handling..... Pin
Luc Pattyn23-Jul-07 6:13
sitebuilderLuc Pattyn23-Jul-07 6:13 
GeneralRe: Module handling..... Pin
Arish rivlin23-Jul-07 6:20
Arish rivlin23-Jul-07 6:20 

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.