protected void Button1_Click(object sender, EventArgs e)
{
string shop_id=Session["shop_id"];
string oldcard,newcard,reason,description;
int ret;
if (this.txtoldcard.ToString() == ""||this.txtnewcard.ToString()=="")
{
return;
}
oldcard = this.txtoldcard.ToString();
newcard = this.txtnewcard.ToString();
reason = "000"+this.DropDownList1.SelectedIndex.ToString();
description = this.TextBox1.ToString();
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
string param = "proc1";
conn.Open();
SqlCommand cmd = new SqlCommand(param, conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter paramshop_id = new SqlParameter("@shop_id", SqlDbType.VarChar);
SqlParameter paramoldcard = new SqlParameter("@oldcard ", SqlDbType.VarChar);
SqlParameter paramnewcard = new SqlParameter("@newcard ", SqlDbType.VarChar);
SqlParameter paramreason = new SqlParameter("@reason", SqlDbType.VarChar);
SqlParameter paramdescription = new SqlParameter("@description", SqlDbType.VarChar);
SqlParameter paramret = new SqlParameter("@ret", SqlDbType.VarChar, 4);
// SqlParameter parammorderid = new SqlParameter("@orderid", SqlDbType.VarChar, 500);
try
{
paramshop_id.Value = shop_id;
paramoldcard.Value = oldcard;
paramnewcard.Value = newcard;
paramreason.Value = reason;
paramdescription.Value = description;
//paramret.Value = lInfo; paramret.Direction = ParameterDirection.Output;
//parammorderid.Direction = ParameterDirection.Output; cmd.Parameters.Add(paramshop_id);
cmd.Parameters.Add(paramoldcard);
cmd.Parameters.Add(paramnewcard);
cmd.Parameters.Add(paramreason);
cmd.Parameters.Add(paramdescription);
cmd.Parameters.Add(paramret); cmd.ExecuteNonQuery();
}
catch (Exception e1)
{
}
}
运行时报的错误是错误无法将类型“object”隐式转换为“string”。存在一个显式转换(是否缺少强制转换?) 麻烦各位大侠帮忙看一下是什么原因,谢谢。
{
string shop_id=Session["shop_id"];
string oldcard,newcard,reason,description;
int ret;
if (this.txtoldcard.ToString() == ""||this.txtnewcard.ToString()=="")
{
return;
}
oldcard = this.txtoldcard.ToString();
newcard = this.txtnewcard.ToString();
reason = "000"+this.DropDownList1.SelectedIndex.ToString();
description = this.TextBox1.ToString();
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
string param = "proc1";
conn.Open();
SqlCommand cmd = new SqlCommand(param, conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter paramshop_id = new SqlParameter("@shop_id", SqlDbType.VarChar);
SqlParameter paramoldcard = new SqlParameter("@oldcard ", SqlDbType.VarChar);
SqlParameter paramnewcard = new SqlParameter("@newcard ", SqlDbType.VarChar);
SqlParameter paramreason = new SqlParameter("@reason", SqlDbType.VarChar);
SqlParameter paramdescription = new SqlParameter("@description", SqlDbType.VarChar);
SqlParameter paramret = new SqlParameter("@ret", SqlDbType.VarChar, 4);
// SqlParameter parammorderid = new SqlParameter("@orderid", SqlDbType.VarChar, 500);
try
{
paramshop_id.Value = shop_id;
paramoldcard.Value = oldcard;
paramnewcard.Value = newcard;
paramreason.Value = reason;
paramdescription.Value = description;
//paramret.Value = lInfo; paramret.Direction = ParameterDirection.Output;
//parammorderid.Direction = ParameterDirection.Output; cmd.Parameters.Add(paramshop_id);
cmd.Parameters.Add(paramoldcard);
cmd.Parameters.Add(paramnewcard);
cmd.Parameters.Add(paramreason);
cmd.Parameters.Add(paramdescription);
cmd.Parameters.Add(paramret); cmd.ExecuteNonQuery();
}
catch (Exception e1)
{
}
}
运行时报的错误是错误无法将类型“object”隐式转换为“string”。存在一个显式转换(是否缺少强制转换?) 麻烦各位大侠帮忙看一下是什么原因,谢谢。
解决方案 »
- 关于.net一个首页顶部问题,是外部数据?还是做了封装的?
- ASP.NET 动态调用类
- 基类包括字段“page”,但其类型(System.Web.UI.Page)与控件(System.Web.UI.WebControls.DropDownList)
- 提取url里的数字参数。
- 怎样把session对象写在数组中?
- 大家帮忙估个价.在线等..
- <!-- #include file="Label.aspx" -->急急急!!!!!!!!!!!!!!1
- 如何在web.config可以设置验证模式的。防止用户匿名访问?
- 请问如何实现以下三层结构啊
- DataGrid删除功能的问题。
- 如何将字符写入XML
- 神马情况?开发环境下OK,IIS就有问题
if (this.txtoldcard.ToString() == ""||this.txtnewcard.ToString()=="")
{
return;
}
oldcard = this.txtoldcard.ToString();
newcard = this.txtnewcard.ToString();
this.txtoldcard.Text;
this.txtnewcard.Text;
=>
description = this.TextBox1.Text;
if (Session["shop_id"] != null)
{
shop_id=Session["shop_id"].ToString();
}