方法'dispdata'的重载没有接受'0'参数 [英] No overload for method 'dispdata' takes '0' arguments
本文介绍了方法'dispdata'的重载没有接受'0'参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误::方法"dispdata"的无重载采用"0"参数
Error: : No overload for method ''dispdata'' takes ''0'' arguments
public void dispdata(string catid)
{
con.Open();
SqlCommand cmd = new SqlCommand(" select catname,catdesc from categoryDetail where catid=@catid ", con);
cmd.Parameters.AddWithValue("@catid", catid);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
txtcname.Text = dr["catname"].ToString();
txtcatdesc.Text = dr["catdesc"].ToString();
}
con.Close();
}
protected void btnsubmit_Click(object sender, ImageClickEventArgs e)
{
SqlCommand cmd = new SqlCommand();
con.Open();
string str = "update categorydetail set catname='" + txtcname.Text + "' where catdesc='" + txtcatdesc.Text + "'";
cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
Response.Redirect("CategoryDetail.aspx?Edit=Yes");
con.Close();
dispdata();
}
推荐答案
调用 dispdata 方法时,您需要将字符串值传递给catid.
更新:希望您已按照以下说明更正了代码
You need to pass a string value to catid, when you call dispdata method.
Update: Hope you have corrected your code as follows
protected void btnsubmit_Click(object sender, ImageClickEventArgs e)
{
SqlCommand cmd = new SqlCommand();
con.Open();
string str = "update categorydetail set catname='" + txtcname.Text + "' where catdesc='" + txtcatdesc.Text + "'";
cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();
Response.Redirect("CategoryDetail.aspx?Edit=Yes");
con.Close();
dispdata("ANY STRING VALUE");
}
问候
塞巴斯蒂安
Regards
Sebastian
这篇关于方法'dispdata'的重载没有接受'0'参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文