Click here to Skip to main content
15,886,045 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 12-Aug-18 10:32am

1 solution

Look like the code is missing the "new" keyword

C#
using (SqlConnection conn = new SqlConnection(connectionStr))
 
Share this answer
 
Comments
Member 13946701 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900