-2

I'm new to C# and may be using this all wrong. but this is the part of my code that I'm having problems with.

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using EntitiesLayer;

namespace DataAccessLayer
{
    class DalManager : AbstractDalManager
    {
        private static DalManager _instance = null;
        private static readonly object _lock = new object();
        private static readonly string _connectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\Users\\MADDXYZ\\Desktop\\temp_db.mdf;Integrated Security=True;Connect Timeout=30";

        DalManager() {
            using (SqlConnection sqlCon = new SqlConnection(_connectionString))
            {
            }

        }
....

And this is an image of the Errors I'm having enter image description here

NOTE : when I remove using I get no errors.

I have looked up on the internet but without success , anyone can Help please?

SSD
  • 1,373
  • 2
  • 13
  • 20
AnotherBrick
  • 153
  • 3
  • 6
  • 14
  • 3
    well, It would be great if you'd point out what Im doing wrong so I could maybe learn from it :D – AnotherBrick Jan 27 '18 at 13:30
  • @AnotherBrick I think the idea of instantiating connection object in constructor itself looks weird – rahulaga-msft Jan 27 '18 at 13:33
  • Avoid singletons. If you absolutely need them, never use double check locking, use `Lazy`, never not `lock`. Do not prefix class names with `Abstract`. Use `const string`, not `static readonly string`. Avoid inheritance. – Aluan Haddad Jan 27 '18 at 13:35
  • Post your errors as text, not images. – mason Jan 27 '18 at 14:49
  • The picture of your code doesn't match the posted code. Your image is showing a semi-colon at the end of the using line. – LarsTech Jan 27 '18 at 21:34

1 Answers1

0

You can only use the assemblies that you have referenced in your project.

In the project tree on the right, you see the node with References. From the context menu, you can add a reference to assemblies you want to use.

H. de Jonge
  • 878
  • 7
  • 25
  • I know but I'm not using the types mentioned in the error, Component, IDisposable and IClonable are System types and not Custom types right? – AnotherBrick Jan 27 '18 at 13:36