<td><div align="center"><a href="delete.asp?id=<%=Rs("id")%>">删除</a></div></td>
delete.asp的内容
<!--#include file="conn.asp"-->
<%
sql="delete from comment where id = " &Request.QueryString("id")
Conn.Execute(sql)
%>
也可以把删除写在你的程序最上面里,用一个参数判断你是否点了删除.
<td><div align="center"><a href="?id=<%=Rs("id")%>&del=yes">删除</a></div></td>
<!--#include file="conn.asp"-->
<%
If Request.QueryString("del") = "yes"
sql="delete from comment where id = " &Request.QueryString("id")
Conn.Execute(sql)
End If
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from comment where id<>'' order by id desc"
rs.open sql,conn,1,1
if rs.bof then
Response.Write("现在没有评论。")
Response.end
end if
%>
你用的是什么数据库啊,如果是SQL的话SqlConnection conn = new SqlConnection("") ///数据库连接字符串
string sql = string,Format("update dbo set ('{0}','{1}','{2}','{3}') where ID= '{4}'",bookName,bookPrice,chubanshe,date)
SqlCommand cmd = new SqlCommand(sql,conn)
int result = cmd.ExecuteNonQuery//影响行数
if(result != null)
{Console.WriteLine("更新成功")}
else{Console.WriteLine("更新失败")}
删除的话把语句换成"delete from dbo where ID= '{0}'",bookID
添加:"insert into dbo values('{0}','{1}','{2}','{3}')",bookName,bookPrice,chubanshe,date
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)