关键代码如下:
<form id="form1" name="form1" method="post" action="indexadmin.jsp">
<table width="278" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="65">用户名:</td>
    <td width="213">
      <input name="username" type="text" class="text" maxlength="8"/>
      <span class="STYLE1">*</span></td>
  </tr>
  <tr>
    <td>密&nbsp;&nbsp;码:</td>
    <td><input name="userpwd" type="text" class="text" maxlength="20"/>
      <span class="STYLE1">*</span></td>
  </tr>
  <tr>
    <td>权&nbsp;&nbsp;限:</td>
    <td><input name="usertype" type="text" class="text" maxlength="10"/>
      <span class="STYLE1">*</span></td>
  </tr>
  <tr align="center">
    <td colspan="2">
   <br><input type="submit" name="Submit" value="提交"/>&nbsp;
   <input type="reset" name="reset" value="重置"/></td>
  </tr>
</table>
</form>
<%
String username = "";
String userpwd = "";
String usertype = "";
if(request.getParameter("username") != null && request.getParameter("userpwd") != null && request.getParameter("usertype")!=null){
username = request.getParameter("username");
userpwd = request.getParameter("userpwd");
usertype = request.getParameter("usertype");
}
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url = "jdbc:microsoft:sqlserver://GCDC_SQL04:1433;DatabaseName=gclnit";
String user = "GCLNITUSER";
String password = "Extract70";
String sql = "INSERT INTO gclnit.gclnituser.lnuser VALUES('"+username+"','"+userpwd+"','"+usertype+"')";
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
stmt.executeUpdate(sql);
%>
当第一次进入网页时,插入数据库为一条空记录,每次刷新也都是空记录,现在想请高手帮忙修改,当进入网页时,不更新数据库,而只有在文本框输入了完整内容,才能插入数据,请给个代码。

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【dazui521】截止到2008-07-28 14:06:00的历史汇总数据(不包括此帖):
    发帖的总数量:25                       发帖的总分数:360                      每贴平均分数:14                       
    回帖的总数量:13                       得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:25                       结贴的总分数:360                      
    无满意结贴数:10                       无满意结贴分:250                      
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:40.00 %               无满意结分率:69.44 %                  
    敬礼!