Click here to Skip to main content
15,843,593 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to disable keydown event in Context Menu Strip ? Pin
Gareth H24-Jan-08 1:30
Gareth H24-Jan-08 1:30 
GeneralRe: How to disable keydown event in Context Menu Strip ? Pin
Varad_Rajan24-Jan-08 1:32
Varad_Rajan24-Jan-08 1:32 
GeneralRe: How to disable keydown event in Context Menu Strip ? Pin
Varad_Rajan24-Jan-08 1:34
Varad_Rajan24-Jan-08 1:34 
GeneralRe: How to disable keydown event in Context Menu Strip ? Pin
Anthony Mushrow24-Jan-08 2:03
professionalAnthony Mushrow24-Jan-08 2:03 
QuestionHow to Change or Generate a file with Owner using .NET 1.1 Pin
Ninerocky24-Jan-08 0:29
Ninerocky24-Jan-08 0:29 
Questionhow to add .rpt and .cri extensions in IIS (windows 2000 with crystal reports 9 installed on the same) Pin
here2learn24-Jan-08 0:06
here2learn24-Jan-08 0:06 
GeneralSqlConnection and scope Pin
Dewald23-Jan-08 23:40
Dewald23-Jan-08 23:40 
GeneralRe: SqlConnection and scope Pin
N a v a n e e t h24-Jan-08 0:03
N a v a n e e t h24-Jan-08 0:03 
Dewald wrote:
I suppose one solution would be to pass the SqlConnection as a parameter to the function that will be working on it but for some reason I don't like that.


Why ? That is the easy method. You can do it like
using (SqlConnection mySqlConnection = new SqlConnection(...))
{
   myFunc1(ref mySqlConnection );
   myFunc2(ref mySqlConnection );
}


If you don't want to pass the connection, try the following.
private SqlConnection mySqlConnection = null;
using (mySqlConnection = new SqlConnection(...))
{
   myFunc1();
   myFunc2();
}
In this mySqlConnection is declared as private in the class. So you will get access to all methods.

When I have created a DAL, I implemented IDisposable interface and provided a Dispose() method which clears my SQLConnection instance. It will be instantiated in the constructor. So it would look like
public class MyDAL : IDisposable
{
   SQLConnection mySqlConnection = null;
   public MyDAL()
   {
       mySqlConnection = new SqlConnection(...);
   }

   public void Dispose()
   {
        //Dispose connection here
   } 
}

You can call this like
using(MyDAL dal = new MyDAL())
{
    //Call MyFun1,MyFun2
}
In the above code, you haven't passed any parameters to the methods.

Hope it helps


All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia

My Website | Ask smart questions


QuestionCopy Contents in Excel Pin
mohankatari23-Jan-08 23:00
mohankatari23-Jan-08 23:00 
GeneralRe: Copy Contents in Excel Pin
Paul Conrad24-Jan-08 8:03
professionalPaul Conrad24-Jan-08 8:03 
Questionhow can i access the xml file in the in richtextbox in c#.net? Pin
samidhas23-Jan-08 22:01
samidhas23-Jan-08 22:01 
AnswerRe: how can i access the xml file in the in richtextbox in c#.net? Pin
N a v a n e e t h24-Jan-08 0:04
N a v a n e e t h24-Jan-08 0:04 
Generalstatus bar Pin
mahenputta23-Jan-08 21:11
mahenputta23-Jan-08 21:11 
GeneralRe: status bar Pin
DaveyM6924-Jan-08 1:58
professionalDaveyM6924-Jan-08 1:58 
GeneralRe: status bar Pin
mahenputta24-Jan-08 2:36
mahenputta24-Jan-08 2:36 
GeneralRe: status bar Pin
DaveyM6924-Jan-08 2:45
professionalDaveyM6924-Jan-08 2:45 
GeneralRe: status bar Pin
mahenputta24-Jan-08 2:51
mahenputta24-Jan-08 2:51 
QuestionHow to make an auto-update tool? Pin
hio7723-Jan-08 20:42
hio7723-Jan-08 20:42 
GeneralRe: How to make an auto-update tool? Pin
Giorgi Dalakishvili23-Jan-08 22:17
mentorGiorgi Dalakishvili23-Jan-08 22:17 
GeneralRe: How to make an auto-update tool? Pin
N a v a n e e t h24-Jan-08 0:05
N a v a n e e t h24-Jan-08 0:05 
Questionhow to save ? Pin
samidhas23-Jan-08 20:15
samidhas23-Jan-08 20:15 
GeneralRe: how to save ? Pin
N a v a n e e t h24-Jan-08 0:07
N a v a n e e t h24-Jan-08 0:07 
GeneralURL monitoring Pin
Adeel Chaudhry23-Jan-08 18:26
Adeel Chaudhry23-Jan-08 18:26 
GeneralRe: URL monitoring Pin
Paul Conrad23-Jan-08 18:53
professionalPaul Conrad23-Jan-08 18:53 
GeneralRe: URL monitoring Pin
Adeel Chaudhry23-Jan-08 19:01
Adeel Chaudhry23-Jan-08 19:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.