Change the connectionString Arg by values data entry by the user in an input with Razor Web Page

StackOverflow https://stackoverflow.com/questions/21305719

Domanda

First, I quite apologize to you for my poor English (cause I'm french). My problem is that, I need to recover some data like server IP, user name and password witch was get back by the user in some input on submit and use these data for change the connectionString witch is in web.config. But I don't know how to do.

I hope to have been clear and thank you in advance for your help.

È stato utile?

Soluzione

Well, after a lot of search and work, I have chose to change my connectionString like it:

@{
    Layout = "~/_Layout.cshtml";
    Page.Title = "Dossier Racine";
    var srv = Request.QueryString["server"];
    var usr = Request.QueryString["username"];
    var pwd = Request.QueryString["password"];  
    var db = Database.OpenConnectionString("server="+srv+";database=ReportServer;uid="+usr+";pwd="+pwd+"","System.Data.SqlClient");    
    var sqlFile = " SELECT *"
        + " FROM Catalog";
    var selectedData = db.Query(sqlFile);    
 }
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top