紧急求助ExecuteNonQuery: CommandText 属性尚未初始化
我的后台程序改了一下后,新增可以正常保存,但在现有的内容编辑后,就出现了“ExecuteNonQuery: CommandText 属性尚未初始化 ”
程序如下:
if (Session["action"].ToString() == "edit")
{
try
{//修改数据库
string Edittext = new Common().GetText(txtContent.Text);
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ToString());
SqlCommand comm = new SqlCommand("", conn);
//"update Article set"
// + "[News_first_title]='" + tbox_FirTitle.Text + "',"
// + "[News_second_title]='" + tbox_SecTitle.Text + "',"
// + "[News_third_title]='" + tbox_ThdTitle.Text + "',"
// + "[News_time]='" + tbox_Date.Text + "',"
// + "[News_author]='" + tbox_Author.Text + "',"
// + "[News_content]='" + Edittext + "',"
// + "[News_homepage_tag]='" + chk_HomePage.Checked + "',"
// + "[News_photo_tag]='" + chk_Flash.Checked + "',"
// + "[News_affiche_tag]='" + chk_Affiche.Checked + "',"
// + "[News_top_tag]='" + chk_Top.Checked + "',"
// + "[news_public_tag]='" + chk_Public.Checked + "',"
// + "[news_hot_tag]='" + chk_Hot.Checked + "',"
// + "[News_attachment]='" + str_Attachment + "',"
// + "[news_public_type]='" + ddlist_PublicType.SelectedItem.Text + "',"
// + "[news_affiche_time]='" + tbox_Affiche.Text + "',"
// + "[news_group_mark]='" + Session["type"].ToString()
// + "' WHERE [News_id]='" + Session["keys"] + "'"
if (strID != null)
{
for (int ni = 0; ni < strID.Length; ni++)
{
sql += "insert into [Article] ("
+ "[News_first_title],"
...
+ "VALUES ('" + tbox_FirTitle.Text + "',"
+ "'" + tbox_SecTitle.Text + "',"
...
,"
+ "'" + strID[ni] + "'"
+ ");";
}
}
sql = "delete from Article where News_id ='" + Session["keys"] + "';" + sql;
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
comm.Dispose();
conn.Dispose();
}
catch (Exception f)
{
Response.Write(f.Message.ToString());
}
}
else
{
try
{//存入数据库
string Edittext = new Common().GetText(txtContent.Text);
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConn"].ToString());