update 问题 初学者
update Conews set content= 'Content.Text ',title= 'Title .Text ',time= 'Time.Text ',classname= 'NewsType.Text ' 到底是错在哪里呀,, 初学者
------解决方案--------------------update Conews set content= ' "+Content.Text+ " ',title= ' "+Title .Text+ " ',time= ' "+Time.Text+ " ',classname= ' "+NewsType.Text+ " '
------解决方案--------------------格式还要注意,TIME那个字段用TEXT肯定不行吧,转化一下
------解决方案--------------------strSQL = "update Conews set content= ' " + Content.Text + " ',title= ' " + Title .Text + " ',time= ' " + Time.Text + " ',classname= ' " + NewsType.Text + " ' where ID= " + Convert.ToInt32(Request.QueryString[ "ID "]);
------解决方案-------------------- 'Content.Text '
代表是常量
------解决方案--------------------为什么不用参数啊
------解决方案--------------------where ID=??
------解决方案--------------------int flag = 0;
string Query = "update imglinks set linkname=@name,linkimg=@img,linkurl=@url where linkid=@id ";
SqlComm = new SqlCommand(Query,SqlConn);
SqlComm.Parameters.Add( "@name ", SqlDbType.VarChar, 50).Value = name;
SqlComm.Parameters.Add( "@img ", SqlDbType.VarChar, 50).Value = img;
SqlComm.Parameters.Add( "@url ", SqlDbType.VarChar, 50).Value = url;
SqlComm.Parameters.Add( "@id ", SqlDbType.VarChar, 50).Value = id;
SqlConn.Open();
flag = SqlComm.ExecuteNonQuery();
SqlConn.Close();
return flag;