Dear Sir/Mam
Please tell me how can i define connection string in my class file.i do not want to describe it in web.config for Database Security.
//SqlConnection mainConnectionString = new SqlConnection();
string str = "server=192.1.1.1;database=db;user id=sa;password=.com;";
SqlConnection mainConnectionString = new SqlConnection(str);
// mainConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
// mainConnectionString.ConnectionString=("server=192.1.1.1;database=db;user id=sa;password=.com;").ToString();
string sam =Convert.ToString( mainConnectionString);
i use all this thing but project not working but if use
// mainConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
ConnectionString from web.config
then its working fine.
please tell me how i solve this problem or any alternative to secure dB USER and password.
or any decrypt or encrypt method use for web.config.

Sanjay SabariyaPosted Jun 8, 2015, 8:43 AM
Nilesh JadavPosted Jun 8, 2015, 8:36 AM
Try this -
You can get your Connection String by going to the database (In Server Explorer right-click on you database then select"Properties". You will then see “Connection String” there. Copy it and paste it into the SQL connection field. Yeah! Surely your connection string is quite different from mine, initially it look like this:
Before
C:\Users\Nilesh\Documents\Visual Studio 2010\WebSites\WebSite13\App_Data -- > Remove this
And add this "|DataDirectory|".
After
Rajeesh MenothPosted Jun 8, 2015, 5:19 AM
सौरभ माहेश्वरीPosted Jun 8, 2015, 4:45 AM
Lalit RaghavPosted Jun 8, 2015, 3:29 AM