1
Answer

getting Data Source Value Dynamically is still returning null value

charan sekhar

charan sekhar

14y
2.9k
1

hi, iam using asp.net2.0 with c#
i want to  get  dynamically the Data Source value   from which system iam acessing the website and concatenate in connection String
but still showing null  value
can you correct my code which helps me
 

 
string
strcon = "Initial Catalog=POS;User ID=sa;Password=103";
protected void Page_Load(object sender, EventArgs e)
{

if (Page.IsPostBack == false)
{
string[] parts = strcon.Split(';');
 

 
string dataSource = "";
for (int i = 0; i < parts.Length; i++)
{
string part = parts[i].Trim();
if (part.StartsWith("Data Source="))
{
dataSource = part.Replace(
"Data Source=", "");
break;
}
}
}
}
Answers (1)