Reputation: 13
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
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