varchar到money的转换?
try{
string shipname1 = this.TextBox1.Text.Trim();
string companyname1 = this.TextBox3.Text.Trim();
string portofregistry1 = this.TextBox5.Text.Trim();
string peccancytime1 = this.Text1.Value.ToString().Trim();
string peccancyplace1 =this.TextBox2.Text.Trim();
string peccancyreason1 = this.TextBox4.Text.Trim();
Decimal peccancymoney1 = Convert.ToDecimal(this.TextBox6.Text.Trim());
string pk = shipname1 + peccancytime1;
Regex re=new Regex(@"^[0-9]+$");
//连接数据库
string strConnection = "data source=(local);user id=sa; password = sa;initial catalog=cjg";
myconn = new SqlConnection(strConnection);
if(shipname1!=""&&companyname1!=""&&portofregistry1!=""&&peccancytime1!=""&&peccancyplace1!=""&&peccancyreason1!=""&&TextBox6.Text!="")
{
myconn.Open();
string insertstr = "insert into [peccancy](shipname,companyname,portofregistry,peccancytime,peccancyplace,peccancyreason,peccancymoney,pk) values ('"+shipname1+"','"+companyname1+"','"+portofregistry1+"','"+peccancytime1+"','"+peccancyplace1+"','"+peccancyreason1+"','"+@peccancymoney1+"','"+pk+"')";
SqlCommand cmd = new SqlCommand(insertstr,myconn);
cmd.Parameters.Add("@peccancymoney1",peccancymoney1);
cmd.ExecuteNonQuery();
//关闭连接
myconn.Close();
//
Response.Write("<script language=javascript>alert('保存成功!')</script>") ;
this.BindData();
//
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox5.Text = "";
TextBox6.Text = "";
this.Text1.Value = "";
//this.TextBox8.Text = "";
//TextBox7.Text = "";
//TextBox10.Text = "";
}
else
{
Response.Write("<script language=javascript>alert('请填满所有项!')</script>") ;
}
}
catch(Exception ex)
{
throw ex;
}
这段程序报“/WebApplication1”应用程序中的服务器错误。
--------------------------------------------------------------------------------
不允许从数据类型 varchar 到数据类型 money 的隐性转换(表 'cjg.dbo.peccancy',列 'peccancymoney')。请使用 CONVERT 函数来运行此查询。
这样的错误,该如何解决?