void button_click(object sender, System.EventArgs e)
{
SqlConnection cn = new SqlConnection(strconn);
cn.Open();
string strSQL = "Insert Into maillist(@receiver,@subject,@content,@rtime,@status) value(receiver,subject,content,DataTime.Today,status)";
SqlCommand myCommand= new SqlCommand(strSQL,cn);
myCommand.Parameters.Add(new SqlParameter("@sender",SqlDbType.NVarChar,20,Request["username"]));
myCommand.Parameters.Add(new SqlParameter("@receiver",SqlDbType.NVarChar,20,receiver.Text));
myCommand.Parameters.Add(new SqlParameter("@subject",SqlDbType.NVarChar,20,subject.Text));
myCommand.Parameters.Add(new SqlParameter("@rtime",SqlDbType.DateTime,8,DateTime.Today.ToString()));
myCommand.Parameters.Add(new SqlParameter("@content",SqlDbType.NVarChar,1000,Textarea1.Value));
myCommand.Parameters.Add(new SqlParameter("@status",SqlDbType.VarChar,50,"未读"));
myCommand.ExecuteNonQuery();
cn.Close();
Response.Redirect("list.aspx");
}
报什么错呀,贴出来看看
string strSQL = "Insert Into maillist (receiver,subject,content,rtime,status) values (@receiver,@subject,@content,@rtime,@status)";
oh, boy, it is your database, cannot you just run the sql first to make sure it works??
SqlCommand myCommand= new SqlCommand(strSQL,cn);
myCommand.Parameters.Add(new SqlParameter("@receiver",SqlDbType.NVarChar,20,receiver.Text));
myCommand.Parameters.Add(new SqlParameter("@subject",SqlDbType.NVarChar,20,subject.Text));
myCommand.Parameters.Add(new SqlParameter("@rtime",SqlDbType.DateTime,8,DateTime.Now));
myCommand.Parameters.Add(new SqlParameter("@content",SqlDbType.NVarChar,1000,Textarea1.Value));
myCommand.Parameters.Add(new SqlParameter("@status",SqlDbType.VarChar,50,"未读"));