救命! ! ! ! CS1955非可调用成员'sqlconnection'不能像方法一样使用。 [英] HELP! ! ! ! CS1955 non-invocable member 'sqlconnection' cannot be used like a method.

查看:803
本文介绍了救命! ! ! ! CS1955非可调用成员'sqlconnection'不能像方法一样使用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎无法理解这个错误,任何帮助都非常感激。



不可调用的成员'SqlConnection'不能像一个方法一样使用。以粗体突出显示。



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;



我尝试过:



似乎无法理解这个错误,任何帮助都非常感激。



不可调用的成员'SqlConnection'不能像一个方法一样使用。以粗体突出显示。

解决方案

看起来代码缺少新关键字



 使用(SqlConnection conn =  new  SqlConnection(connectionStr))


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.

解决方案

Look like the code is missing the "new" keyword

using (SqlConnection conn = new SqlConnection(connectionStr))


这篇关于救命! ! ! ! CS1955非可调用成员'sqlconnection'不能像方法一样使用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆