Click here to Skip to main content
15,885,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All

i knew it it is stupid question but i don't know so ask you all expert need help


C#
try
            {
                using (MySqlConnection con = new MySqlConnection(txtOtherConStr.Text.Trim()))
                {
                    foreach()
                    {
                    
                    }
                    
                    }

          }


This is my code my connection string in the txtOtherConStr.Text(data source=localhost; uid=root; pwd=root; database=Hr;)

i want to database=Hrhow can i get pls help meeeeeee
Posted
Comments
Kornfeld Eliyahu Peter 4-Mar-14 2:11am    
Did you heard about regex?

I am not a Regex expert but this pattern would be a good start I guess: database=(.*?). You can then use Match.Groups property to get the database name.
 
Share this answer
 
Comments
Arjunwalmiki 4-Mar-14 2:26am    
Sorry i don't know this
dan!sh 4-Mar-14 2:27am    
Check out about Regex on MSDN
C#
First Take txtOtherConStr.Text in a string like string st=txtOtherConStr.Text.Trim()
then split it by (;) like
string []st1=st.split(;) then You have st1[0],st1[1],t1[2],st1[3]..Now find string which have database .

i think itis st1[3] now spilt it again by (=).. then u have the databasename
 
Share this answer
 
v2
Comments
Arjunwalmiki 4-Mar-14 2:25am    
ErBhati,

string st = txtOtherConStr.Text.Trim();
string []st1=st.Split(;);
st=st1[3];

is this right?
ErBhati 4-Mar-14 2:33am    
Arjun
string st = txtOtherConStr.Text.Trim();
string []st1=st.Split(;);
after this
string [] ss=st1[3].spilt('=');
now u have ss[0] and ss[1].
I think this solve your problem
ErBhati 4-Mar-14 7:11am    
plz select as answer for others if it helps you....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900