|
public static string sqlConnectionString = "packet size=4096;user id=sa;data source=" + "." + ";persist security info=True;initial catalog=plan;password=aaa";
plan 1.
string[] str = sqlConnectionString.Split( new char[]{'=',':'});
for(int i = 0;i<str.Lenght;i++
{
switch(str[i])
{
case "user id":
username=str[i+1];i++;break;
case"password":
pwd=str[i+1];i++;break;
default:
break;
}
}
Scenario 2.
username = "user id=";
pwd="password=";
int pos1 = sqlCOnnectionString.Find(username);
int pos2 = sqlCOnnectionString.Find(";",pos1);
username = sqlCOnnectionString.SubString(pos1+username.Length,pos2);
pwd....
Option 3.
Regular // MSDN is not there, I can't write it out |
|