本文介绍了此SqlParameterCollection不包含带有ParameterName'empaddress'的SqlParameter。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨所有
i执行以下代码时出现上述错误
但是empname也显示在.cs文件中插入断点
hi all
i got the above error when executing below code
but empname is also showed while inserting break point in .cs file
cmd = new SqlCommand("pdetails", con);
cmd.CommandType = CommandType.StoredProcedure;
p1 = new SqlParameter("@empid", SqlDbType.Int,50);
p1.Value = Convert.ToInt32(cmbexistingemp.SelectedValue);
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empname", SqlDbType.VarChar,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empsex", SqlDbType.VarChar,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empdob", SqlDbType.Date,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empmobileno", SqlDbType.VarChar,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empaddress", SqlDbType.VarChar,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empnationality", SqlDbType.VarChar,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empdesig", SqlDbType.VarChar,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empskill", SqlDbType.VarChar,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
p1 = new SqlParameter("@empmailid", SqlDbType.VarChar,50);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
txtename0.Text = cmd.Parameters["@empname"].Value.ToString();
//txtsex0.Text = cmd.Parameters["empsex"].Value.ToString();
// txtdob0.Text =cmd.Parameters["empdob"].Value.ToString();
txtaddress0.Text = cmd.Parameters["empaddress"].Value.ToString();
txtmobileno0.Text = cmd.Parameters["empmobileno"].Value.ToString();
txtmailid0.Text = cmd.Parameters["empmailid"].Value.ToString();
txtnationality0.Text = cmd.Parameters["empnationality"].Value.ToString();
txtdesignation0.Text = cmd.Parameters["empdesig"].Value.ToString();
txtempskill0.Text = cmd.Parameters["empskill"].Value.ToString();
推荐答案
txtaddress0.Text = cmd.Parameters["@empaddress"].Value.ToString();
这篇关于此SqlParameterCollection不包含带有ParameterName'empaddress'的SqlParameter。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!