Link to home
Create AccountLog in
Avatar of Jacque Scott
Jacque ScottFlag for United States of America

asked on

Visual Studio 2012 How to find the existing connection string

I need to update a project and I am looking for the DB connection string.  It is not in an obvious place.  Here is how we call the DB.
String cs3 = "INSERT INTO tblWP_TS_Day VALUES(NEWID(),@sd,@st,@et,@lit,@lot,@nt,@ot,@sit,@hot,@vat,@tt,@euk,@ct,'');";
                        Cm.ex(Cm.plw, cs3, null, ch, null, null, null, null, null, null, false);

Open in new window

The 'plw' contains the connection string but I can't find where that is set.  I right clicked on it and went to 'Go To Definition' and it brought me to this.

namespace BaseClassLibrary
    public class Cm
        public static string cp;
        public static string plc;
        public static string pld;
        public static string pldt;
        public static string plw;

        public Cm();

        public static string ex(string cmm, string fc, string cmt, Hashtable ch, string ot, Ob rob, ArrayList al, Ts gts, Dl gdl, Label rl, bool q);

Open in new window

I am trying to find where these variables are set.  I've done a search on the whole project and nothing shows up.  I am thinking there is a 'behind the scenes' spot where it can be set in a project.  I've looked in the 'Properties' page and clicked through each link and can't find it.  

Any idea?

Avatar of Arana (G.P.)
Arana (G.P.)

do you even know the name of the database? try searching for your database name or your username in the whole project, Since we can see the rest of the code I would also look into ODBC data sources in control panel. or in the project DATASOURCES
Avatar of Jacque Scott


Where do I find the project DataSources?  I have tried to search for my database name and can't find it.
I clicked on the 'Data Sources' on the far left and it states that there are none to show.
do you have any  third party addons in your project? (infrgistics or similar? ), or data binding controls? if you have then the connection might be a property in one of them:

Can you set variables in a library?
I mean in design mode control properties.
I found it.  I was stepping through my program and it brought me to a page that had all of the variables for the DB set.  It is called Cm.cs.  I am looking for this page under the Solution Explorer and I don't see it.  Because of the extension '.cs' I looked under the 'Classes' and I don't see 'Cm.cs' there, I also looked in all of those links.

Any idea of how to find this page again?
The namespace is BaseClassLibrary.  How do I get to this file?
Avatar of Arana (G.P.)
Arana (G.P.)

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I found it by looking through the files on my computer.  This file is used on all my programs, which makes sense.  

What I don't get is that I load this library on my program but I wasn't able to search in it or access it unless I step through my code and it loads that page or I open it using 'File - Open'.  Is there any other way of opening it?
Is this code obfuscated? Your variable names don't look very sensible, which is usually the kind of thing an obfuscator would do.
The variables are very obfuscated but I am unable to change the code that was already written.  :-(
Thank you for all of your help.  I know I didn't give much to go on but I didn't know what to give.  

Thanks again!!!
OK, the variables are, but I'm specifically asking if your code is obfuscated. Because typically obfuscators will have logic built in that defeats reverse engineering the code (for hopefully obvious reasons). If this code was run through an obfuscator, then you'll probably have a difficult time tracing through it.
The person who wrote the program did not write any notes or very few.  I have never heard of an obfuscator before.  I doubt the programmer used one.