电子商务网站平台3p设计技术与网络数据库
('data1','data2','data3','data4','data5', 'data5')"; set rs=conn.execute(sql) 更改某条数据记录: sql="update tablename set data1="request(ptwbk )", where ID="num"; set rs=conn.execute(sql) 删除某条数据记录: sql="delete from tablename where ID="num";set rs=conn.execute(sql) 将SQL语句处理的数据结果输出 Response.Write "
" Response.Write " " For i=0 to rs.Fields.Count-1 Response.WRITE " " & rs.Fields(i).Name & " " Next Response.Write "
" While Not rs.EOF Response.Write " " For i=0 to rs.Fields.Count-1 Response.WRITE " " & rs.Fields(i).Value & " " Next Response.Write "
" rs.MoveNext Wend Response.Write "
" 关闭数据库: rs.close;conn.Close
5.2设计处理表单数据的PHP程序 form_cl.php 建立与数据库的连接:这里采用PHP的MySql函数法(也可用ODBC函数法) $conn=odbc_connect("localhost","user","xxxxxx"); 选择数据库: mysql_select_db("tradedb","$conn"); 获去表单提交的数据: $data1=$ptwbk; $data2=$mmwbk; $data3=$gdwbk; $data4=$dxk; $data5=$fxk; $data6=$lbk; 用SQL语句对数据库进行操作 查询数据记录: $sql="select * from tablename&quo
5.3设计处理表单数据的JSP程序 form_cl.jsp 建立与数据库的连接:这里采用JDBC-ODBC桥生成JavaBean法 创建一个JavaBean命名为conndb.java,并保存在d:/resin1.1.3/doc/web-inf/classes/trade目录下,代码如下:(限于篇幅这里没按标准书写,而采用不换行写法,其他类同) package trade; import java.sql.*; public class conndb { String url="jdbc:inetdae:localhost";String login="user"; String password = "xxxxxx"; String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";String sConnStr = "jdbc:odbc:Dsnmysql"; Connection conn = null; ResultSet rs = null; public conndb() {try {Class.forName(sDBDriver); Connection conn = DriverManager.getConnection(url,login,password);} catch(java.lang.ClassNotFoundException e) {System.err.println("conndb(): " + e.getMessage ());}} Public/ResultSet/executeQuery(String/sql)/{rs=null;t 《电子商务网站平台3p设计技术与网络数据库(第3页)》
本文链接地址:http://www.oyaya.net/fanwen/view/169018.html
" Response.Write " " For i=0 to rs.Fields.Count-1 Response.WRITE " " & rs.Fields(i).Name & " " Next Response.Write "
" While Not rs.EOF Response.Write " " For i=0 to rs.Fields.Count-1 Response.WRITE " " & rs.Fields(i).Value & " " Next Response.Write "
" rs.MoveNext Wend Response.Write "
" 关闭数据库: rs.close;conn.Close
5.2设计处理表单数据的PHP程序 form_cl.php 建立与数据库的连接:这里采用PHP的MySql函数法(也可用ODBC函数法) $conn=odbc_connect("localhost","user","xxxxxx"); 选择数据库: mysql_select_db("tradedb","$conn"); 获去表单提交的数据: $data1=$ptwbk; $data2=$mmwbk; $data3=$gdwbk; $data4=$dxk; $data5=$fxk; $data6=$lbk; 用SQL语句对数据库进行操作 查询数据记录: $sql="select * from tablename&quo
t; ;$result=odbc_do($conn,$sql); 增加数据记录: $sql="insert into tablename(ptwbk,mmwbk,gdwbk,dxk,fxk,lbk) values('$data1','$data2','$data3','$data4','$data5','$data6')";$result=odbc_do($conn,$sql); 更改某条数据记录: $sql="update tablename set $data1=ptwbk where ID=num" $result=odbc_do($conn,$sql); 删除某条数据记录:$sql="delete from tablename where ID=num";$result=odbc_do($conn,$sql); 将SQL语句处理的数据结果输出 odbc_result_all($result,"border=1"); 关闭数据库: odbc_close($conn);
5.3设计处理表单数据的JSP程序 form_cl.jsp 建立与数据库的连接:这里采用JDBC-ODBC桥生成JavaBean法 创建一个JavaBean命名为conndb.java,并保存在d:/resin1.1.3/doc/web-inf/classes/trade目录下,代码如下:(限于篇幅这里没按标准书写,而采用不换行写法,其他类同) package trade; import java.sql.*; public class conndb { String url="jdbc:inetdae:localhost";String login="user"; String password = "xxxxxx"; String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";String sConnStr = "jdbc:odbc:Dsnmysql"; Connection conn = null; ResultSet rs = null; public conndb() {try {Class.forName(sDBDriver); Connection conn = DriverManager.getConnection(url,login,password);} catch(java.lang.ClassNotFoundException e) {System.err.println("conndb(): " + e.getMessage ());}} Public/ResultSet/executeQuery(String/sql)/{rs=null;t 《电子商务网站平台3p设计技术与网络数据库(第3页)》