from one ASP page to other with variable and change connection string
i have 2 ASP pages in first page the user choose the database name and in other page take the database name and change the connection string to other database how i can pass a variable from one page to other by button click and how i receive this variable in other page and how to change the connection string the connection string is in web.config like this:
<connectionStrings>
<add name="Northwind" connectionString="Provider=sqloledb;Data Source=.;Init开发者_高级运维ial Catalog=Northwind;User Id=sa;Password=sa; Connect Timeout=10"/>
</connectionStrings>
plz help me as soon as possible
Don't have the user choose the full connection string, it's huge security issue plus pretty cumbersome for the user himself.
Instead, have several connection strings in the config file:
<connectionStrings>
<add name="Northwind" connectionString="Provider=sqloledb;Data Source=.;Initial Catalog=Northwind;User Id=sa;Password=sa; Connect Timeout=10"/>
<add name="Westwind" connectionString="..."/>
<add name="Eastwind" connectionString="..."/>
</connectionStrings>
Then pass the name only on the URL e.g. MyPage.aspx?connstringname=Eastwind and finally use that parameter from the URL when you read the connection string:
string strConnString = ConfigurationManager.ConnectionStrings[Request.QueryString["connstringname"]].ConnectionString;
精彩评论