Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EndExecuteNonQuery错误_C#_Asp.net_Sql - Fatal编程技术网

C# EndExecuteNonQuery错误

C# EndExecuteNonQuery错误,c#,asp.net,sql,C#,Asp.net,Sql,我在按钮单击事件上有一个错误,因为它在这一行上向我显示了一条错误消息: com.endexecutenquery() 消息文本:错误2方法“EndExecuteNonQuery”没有重载接受0个参数 谢谢你的支持 protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { SqlConnection conn = new SqlConnection(Configuration

我在按钮单击事件上有一个错误,因为它在这一行上向我显示了一条错误消息:

com.endexecutenquery()

消息文本:错误2方法“EndExecuteNonQuery”没有重载接受0个参数

谢谢你的支持

  protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["usradmadslistview"].ConnectionString);
        conn.Open();

        string cmdStr = "Select count(*) from UserInfo where UID = '" + UsrNme.Text + "'";
        SqlCommand com = new SqlCommand(cmdStr, conn);
        int temp = Convert.ToInt32(com.ExecuteScalar().ToString());


        if (temp == 1)
        {
            chkusrnamlbl.Visible = true;
        }

        conn.Close();
    }
}





protected void btnSave_Click(object sender, EventArgs e)
{
    try
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["usradmadslistview"].ConnectionString);
        conn.Open();

        string insertquery = "insert into UserInfo (UID,FN,LN,Password,Email,CountID,State,City) Values (@username,@firstn,@lastn,@passbox,@email1,@country,@state,@city)";
        SqlCommand com = new SqlCommand(insertquery, conn);
        com.Parameters.AddWithValue("@username", UsrNme.Text);
        com.Parameters.AddWithValue("@firstn", fnbox.Text);
        com.Parameters.AddWithValue("@lastn", lnamebox.Text);
        com.Parameters.AddWithValue("@passbox", passtxtbx1.Text);
        com.Parameters.AddWithValue("@email1", emailbox.Text);
        com.Parameters.AddWithValue("@country", DrDncoundrlst.SelectedItem.ToString());
        com.Parameters.AddWithValue("@state", DropDownListSwestate.SelectedItem.ToString());
        com.Parameters.AddWithValue("@city", citytxtbox.Text);

        com.EndExecuteNonQuery();
        Response.Redirect("User panel.aspx");

        conn.Close();
    }

   catch(Exception ex) {
        Response.Write("Error:" + ex.ToString());
    }

endexecutenquery
需要前面提到的
IAsyncResult
参数


还有,这只是一个代码片段吗?因为我认为您应该使用
com.ExecuteNonQuery()
EndExecuteNonQuery
是异步执行SQL语句的结束对。

不应调用ExecuteNonQuery…Begin和end ExecuteNonQuery用于异步执行SQL语句。我相信那不是你想要的,因为我看不到一个开始