Saturday, 4 August 2012

How to create connection string dynamically


How to create connection string dynamically

Here i am using viewstate to create connection string at run time.

 protected void btnSubmit_Click(object sender, EventArgs e)  

 {   

      ViewState["DataScorceName"] = datasource;  

      ViewState["Customer"] = txtCustomer.Text;  

 }  

 public void MyFunction()  

 {   

      string sqlConnectionString = "Persist Security Info=True;User ID=sa;Password=Sa;Initial Catalog=" + DBName + ";Data Source='" + ViewState["DataScorceName"] + "'";  

 }  

No comments:

Post a Comment

Popular posts