以文本方式查看主题 - 康柏仕电脑学院 (http://combss.com/bbs/index.asp) -- Dreamweaver网站设计交流区 (http://combss.com/bbs/list.asp?boardid=48) ---- 怎样用ASP连接数据库 (http://combss.com/bbs/dispbbs.asp?boardid=48&id=347) |
-- 作者:superpch -- 发布时间:2007/4/18 12:47:00 -- 怎样用ASP连接数据库 数据库连接 <% dim db,conn,myconn db="/database/product.mdb" Set Conn = Server.CreateObject("ADODB.Connection") myconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"") Conn.Open MyConn %> '添加数据 <% name=request.form("name") type_=request.form("type_") about=ubbcode(request.form("about")) pic=request.form("PIC") if name="" or pic="" or type_="" then response.write"错误!内容必须添写!或您没有选择类别" else set sql=conn.execute("Insert Into RY_WH(title,about,pic,type_,time_) Values ('"&name&"','"&about&"','"&pic&"','"&type_&"','"&date()&"')") set sql=nothing response.redirect("q_admin.asp") end if %> '删除数据 <% id=Request.QueryString("id") Set book=server.createobject("adodb.recordset") SQLstr="Delete * from RY_WH where id = " & id conn.Execute SQLstr set book=nothing conn.close set conn=nothing response.redirect("Q_admin.asp") %> 数据修改! <% set rs=server.createobject("adodb.recordset") id=request.form("type") typename_=request.form("typename") sql=("select * from RY_WH_TYPE where id="&id&"") rs.open sql,conn,1,3 rs("typename")=typename_ rs.update rs.close response.redirect("Q_type.asp") %> |