Solved

How to rename an object?

Posted on 2003-12-04
4
261 Views
Last Modified: 2010-04-16
Look at the following code:
I want to rename SQLdbConn to dnConn and it fail to compile.  Dosent recognise the new name...
How should i do it?

      public SqlConnection SQLdbConn;
            
                  public Connection(string conType, string conStr)
                  {
                                 this.openConnection(conType, conStr);
                  }
                  public void openConnection(string conType, string conStr)
                  {
                        //Case resasign dbConn and open connection
                        switch(conType)      
                        {        
                              case "sqlclient":
                                    // use constructor to open the connection
                                    SQLdbConn = dbConn;
                                    dbConn = new SqlConnection(conStr);
                                    dbConn.Open();                        
                                    break;

0
Comment
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
jj819430 earned 250 total points
ID: 9877499
public SqlConnection SQLdbConn;
         
               public Connection(string conType, string conStr)
               {
                              this.openConnection(conType, conStr);
               }
               public void openConnection(string conType, string conStr)
               {
                    //Case resasign dbConn and open connection
                    switch(conType)      
                    {        
                         case "sqlclient":
                              // use constructor to open the connection
                              SQLdbConn = dbConn;   // you are using dbConn here
                              dbConn = new SqlConnection(conStr);  // you are declaring dbConn here
                              dbConn.Open();                    
                              break;

Just switch the two around. so that your switch looks like this:

 switch(conType)      
                    {        
                         case "sqlclient":
                              // use constructor to open the connection
                             
                              dbConn = new SqlConnection(conStr);  // you are declaring dbConn here
                              SQLdbConn = dbConn;   // you are using dbConn here
                              dbConn.Open();                    
                              break;
0
 

Author Comment

by:Yann de Champlain, PMP
ID: 9877609
Thanks.

Stupid I was...
0
 
LVL 7

Expert Comment

by:jj819430
ID: 9878470
eh, everyone does the same stuff. Half the time people just need to have a fresh set of eyes look at it.
0
 

Author Comment

by:Yann de Champlain, PMP
ID: 9878538
yep you right
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question