Solved

How to rename an object?

Posted on 2003-12-04
4
253 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
Comment Utility
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
Comment Utility
Thanks.

Stupid I was...
0
 
LVL 7

Expert Comment

by:jj819430
Comment Utility
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
Comment Utility
yep you right
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now