Shkelqim Haxha
Shkelqim Haxha

Reputation: 13

'SqlConnection' does not contain a constructor that takes 1 arguments

    SqlConnection connection = new SqlConnection(@"Data Source=SHKELQIM\SQLEXPRESS;Initial Catalog=Menagjimi i llogarise bankare;Integrated Security=True");

this is the code which seems all fine in my eye as SqlConnection contains a constructor with an argument, where u can add connection string as an argument, and that's what i'm trying to do, but i'm getting this error... "SqlConnection does not contain a constructor that takes 1 arguments"

i also confirm that i have system.data.sqlclient namespace added to the class, but this just doesn't work

anyone care to help ?

Upvotes: 0

Views: 3690

Answers (1)

John Saunders
John Saunders

Reputation: 161831

Your problem is probably that you have another class named SqlConnection which does not have a one-parameter constructor.

You can confirm this by using the full name of the desired SqlConnection class:

var connection = new System.Data.SqlClient.SqlConnection(connectionString);

Upvotes: 2

Related Questions