关于Message~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c#不是可以内嵌html么,我编了个程序,为什么程序提示我Message不存在?
protected void Button2_Click(object sender, EventArgs e)
{
string insertCmd = "insert into YY9806 (DATE,HBH,DW) values ( @date,@hbh,@dw) ";
string connection = "Data Source=TRACKER;Initial Catalog=ProductStatistics;User ID=sa;Password=12345;timeout=60;Trusted_Connection=yes ";
SqlCommand myCommand = new SqlCommand(insertCmd,new SqlConnection(connection));
myCommand.Parameters.Add(new SqlParameter( "@date ",SqlDbType.NVarChar,8));
myCommand.Parameters[ "@date "].Value = TextBox2.Text;
myCommand.Parameters.Add(new SqlParameter( "@hbh ", SqlDbType.NVarChar,4));
myCommand.Parameters[ "@hbh "].Value = TextBox3.Text;
myCommand.Parameters.Add(new SqlParameter( "@dw ", SqlDbType.NVarChar, 2));
myCommand.Parameters[ "@hbh "].Value = TextBox4.Text;
myCommand.Connection.Open();
//HtmlContainerControl hcc;
try
{
//IAsyncResult res;
myCommand.ExecuteNonQuery();
Message.InnerHtml = " <b> 已添加记录 </b> <br> " + insertCmd;
}
catch(SqlException e1)
{
if (e1.Number == 2627)
Message.InnerHtml = "错误:已存在具有相同主键的记录 ";
else
Message.InnerHtml = "错误:未能添加记录,请确保正确填写了字段 ";
Message.Style[ "color "] = "red ";
}
myCommand.Connection.Close();
&