Results 1 to 2 of 2

Thread: public string; public using

  1. #1
    Fanatic Member
    Join Date
    Oct 06
    Posts
    652

    public string; public using

    i put the code below inside a Module but I encounter an error

    Code:
            public static string ConStr = "Provider=Microsoft.Jet.OleDB.4.0; Data Source =" + Application.StartupPath + "\\db1.mdb";
            public using (OleDbConnection Conn = new OleDbConnection(ConStr))
    what should I do?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    81,261

    Re: public string; public using

    You can only use a 'using' block with local variables. The whole point of a 'using' block is to create an object and dispose it at the end of the block. It wouldn't make sense to dispose an object assigned to a member variable immediately would it? You would get rid of the 'using' and just declare a regular old OleDbConnection variable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •