原始碼:

pingfeng發表於2003-05-08

// <%@ page language="java" import="java.sql.*"%>
<%@ page contentType="text/html;charSet=gb2312"%>
<%@ page import="com.microsoft.jdbc.sqlserver.SQLServerDriver"%>
<html>
<head>
<title>當前票數統計</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<body bgcolor="FFFFFF">
<%
Connection con=null;
Statement stm=null;
String SQLText;
ResultSet Rs_result=null;

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.9.114:1433;DatabaseName=webdev","sa","");
stm=con.createStatement();

SQLText = "select * from zd_xt_qkdm";
Rs_result=stm.executeQuery(SQLText);
String companyName,voteNum;
while(Rs_result.next())
{
companyName=Rs_result.getString(1);
voteNum=Rs_result.getString(2);

%>
    <%=companyName%>
	<%=voteNum%>
<% out.println("<br>");
}
out.println("<br>資料庫連結成功!");
Rs_result.close();
stm.close();
con.close();
%>
</body>
</html>
<p class="indent">

相關文章