考试的题目,求最佳解答
访问purchase.htm网页后,用户录入信息后,通过递交,调用insert.asp,完成将新书插入数据库books表中操作,并返回提示“操作完成”到用户浏览器,试编写insert.asp网页代码。
数据库表截图:
http://img105.photo.163.com/zill55/11653894/260531229.jpg
<html>
<body>
<form method="POST" action="insert.asp">
书号:<input type="text" name="txtbookID">
出版社:<input type="text" name="txtpublish" size="40">
书名:<input type="text" name="txtname" size="40">
定价:<input type="text" name="txtprice">
<input type="submit" value="新增记录" >
</form>
</body>
</html>
提示:一些数据库组件操作命令格式:
1.创建ADO对象:Set newconn=Server.CreateObject("ADODB.Connection")
newconn.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\publish.mdb”
2.创建记录对象:Set rs= Server.CreateObject("ADODB.RecordSet")
3.打开数据表:newconn.Open “books”
4.创建添加新记录SQL语句:SQLcmd="INSERT INTO books(书号,出版社,书名,定价) Values(‘”&txtbookID & “’, ‘” & txtpublish & “’, ‘” & txtname & “’, ‘” & txtprice & “’)”
5.Set rs=newconn.Execute(SQLcmd)
6.关闭记录对象:rs.Close
7.关闭ADO对象:newconn.Close

