charan sekhar

charan sekhar

  • NA
  • 108
  • 0

getting Data Source Value Dynamically is still returning null value

Jul 8 2010 2:56 AM

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)