Solved

How to rename an object?

Posted on 2003-12-04
4
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 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