HI WELCOME TO KANSIRIS

Global Variable Vs Local Variable

Leave a Comment
01public class data{
02 
03 public string getNames(){
04   sqlcommand cmd = new sqlcommand("select .......");
05 }
06 
07 public string getStores(){
08   sqlcommand cmd = new sqlcommand("select .......");
09 }
10 
11}


vs
2
01public class data{
02 
03 sqlcommand cmd;
04 public string getNames(){
05   cmd = new sqlcommand("select .......");
06 }
07 
08 public string getStores(){
09   cmd = new sqlcommand("select .......");
10 }
11}


vs
3
01public class data{
02 
03 sqlcommand cmd = new sqlcommand();
04 public string getNames(){
05   cmd.CommandText = "select ......." ;
06 }
07 
08 public string getStores(){
09   cmd.CommandText = "select .......";
10 }
11}

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.