Locked Database changing for .net application

  • mercredi 4 avril 2012 08:14
     
     
    Hi...i m having two databases in different environments but both are having same data.Presently my application  connecting to  one database .I need to disconnect that database and i want to connect to another database .Is it possible to connect to another database? If Its possible then what are things i have to modify in the application code.
    • Modifié Ashok-n jeudi 5 avril 2012 06:13
    •  

Toutes les réponses

  • mercredi 4 avril 2012 13:21
     
     Traitée

    Hi Ashok,

    Change your SqlConnection ConnectionString to Connect 2nd Database.

    Write Connection Setting in One Encrypted Text File and at the time of launching Application read Database Setting from that text File.

    Regards

    Anand

  • mercredi 4 avril 2012 16:54
     
     Traitée A du code

    It depends on how your application is picking the database connection information. It is a general practice that major application stores this information in app.config/web.config.

    If so you just open the configuration file of your application and look for a section as like below,

    <connectionStrings>
    <add name="myConnectionString" connectionString="server=Some IP or CpmputerName; database=Your DatabaseName;
    uid=myUser;password=myPass;" />
    </connectionStrings>
     

    Replace Database Server information on connection string and save it and restart your application. This does not require you to re-compile your code.

    If this connection string information is hard coded then you are in trouble. You need to modify accordingly and recompile your code and deploy again.


    Lingaraj Mishra

  • jeudi 5 avril 2012 05:54
     
     
    Hi Annand ..thanks for ur reply of my Question..:)
    • Modifié Ashok-n jeudi 5 avril 2012 05:56
    •  
  • jeudi 5 avril 2012 05:55
     
     

    Hi Mishra,

     Thanks for ur reply to my Question...:)