Click here to Skip to main content
13,739,603 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Cant seem to get my head around this error, any help greatly appreciated.

Non-invocable member 'SqlConnection' cannot be used like a method. Highlighted in Bold.

protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnSearch_Click(object sender, EventArgs e)
{
string connectionStr = ConfigurationManager.ConnectionStrings["connectionStr"].ConnectionString;
using (SqlConnection con = SqlConnection (connectionStr))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "spSearchEmployees";
cmd.CommandType = CommandType.StoredProcedure;

What I have tried:

Cant seem to get my head around this error, any help greatly appreciated.

Non-invocable member 'SqlConnection' cannot be used like a method. Highlighted in Bold.
Posted 12-Aug-18 8:55am
Updated 12-Aug-18 10:32am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Look like the code is missing the "new" keyword

using (SqlConnection conn = new SqlConnection(connectionStr))
  Permalink  
Comments
13-Aug-18 3:00am
   
Many thanks, very new to this so more than likely more questions to come.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.180920.1 | Last Updated 12 Aug 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100