打印本文 打印本文  关闭窗口 关闭窗口
ASP与SQL网站数据库程序设计(16)
作者:.. 文章来源:科学出版社 点击数: 更新时间:2004/1/25 1:09:56
41~46行:产生可以新增币别的输入字段。

Currency.asp 程序段

53: <%

54: Function ShowDatas

55: Set OBJConn = Server.CreateObject("ADODB.Connection")

56: OBJConn.Open "Trade", "test", "test1"

57: SQL = "Select * from 币别信息 order by 币别代号"

58: On Error Resume Next

59: Set Rs = OBJConn.Execute(SQL)

60: if not rs.eof then

61:      datas = rs.getrows(500)

62:      response.write "<input type=hidden name='Values' Value='" & ubound(datas,2) & "'>"

63:      %>

64:      <tr>

65:    <td class='ChiDingSt02' bgcolor='tan'>修改</td>

66:    <td class='ChiDingSt02' bgcolor='tan'>删除</td>

67:    <td class='ChiDingSt02' bgcolor='tan'>编号</td>

68:    <td class='ChiDingSt02' bgcolor='tan'>币别缩写</td></tr>

69:      <%

70:      for i = 0 to ubound(datas,2)

71:      %>

72:          <tr><td align='center'><input type='check box' name='Modify<% = i %>'></td>

73:          <td align='center'><input type='checkbox' name='Delete<% = i %>'></td>

74:          <td class='ChiDingSt02' bgcolor='tan' align='center'><% = datas(0,i) %>

75:          <input type='hidden' name ='currencyNo<% = i %>'  Value='<% = datas(0,i)%>'></td>

76:          <td class='ChiDingSt02' bgcolor='tan'> <input type='text' name='currency<% = i %>' value='<% = datas(1,i) %>' size='10'></td>

77:      <% next %>

78:      <tr><td colspan="4" align="center">

79:     <input type="submit" name="Submit" Value= "修改确认"> 

80:     <input type="submit" name="Submit" Value= "确认删除">

81:      </td></tr>

82:      <tr><td colspan="4"> </td></tr>

83: <%

84: end if

85: OBJConn.Close

86: end Function

87: %>

程序说明

57~59行:从表中取出所有的币别信息。

70~77行:根据所取得的RecordSet 数量,自动产生各种输入、选取的字段以及各种功能按钮。

Currency.asp 程序段

89: <%

90: function CreateNewCurrency

91: Set OBJConn = Server.CreateObject("ADODB.Connection")

92: OBJConn.Open "Trade", "test", "test1"

93: SQL = "insert into 币别信息(币别代号,币别名称) values('" & request.form("NewCurrency") & "','" & request.form("NewCurren-cyInfo") & "')"

94: On Error Resume Next

95: Set Rs = OBJConn.Execute(SQL)

96:

97: SQL = "Select * from 币别信息 where trim(币别代号)='" & trim(request.form("NewCurrency")) & "'"

98: Set Rs = OBJConn.Execute(SQL)

99: if not rs.eof then

100:         showinfo "币别新增完成!","/Currency.asp",1

101:     else

102:         showinfo "新增错误!\n可能已经有此币别","",0

103:     end if

104:     OBJConn.Close

105: end function

106: %>

程序说明

本段程序用于检查第41~46行所输入的币别信息是否已经存在于表中,如果是新的币别,则将数据写入“币别信息”表中;反之,则显示相关的信息。

Currency.asp 程序段

109: <%

110: function DeleteCurrency

111:     Set OBJConn = Server.CreateObject("ADODB.Connection")

112:     OBJConn.Open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath("db/mydb.mdb")

113:     On Error Resume Next

114:     Counters = 0

115:     for i = 0 to request.form("Values")

116:         if request.form("Delete" & i) = "on" then

117:             Counters = 1

118:             SQL = " update 产品基本信息 set 币别= 0 where 币别=" & request.form("currencyno" & i )

119:             set rs = objconn.execute(sql)

120:             SQL = "delete from 币别信息 where 编号=" & request.form("currencyno" & i )

121:             set rs = objconn.execute(sql)

122:         end if

123:     next

124:     objconn.close

125:     if counters = 0 then

126:        showinfo "没有选择任何币别!\n\n 删除程序无效!","",0

127:     else

128:         showinfo "币别删除完成!","/Currency.asp",1

129:     end if

130:     OBJConn.Close

131: end function

132: %>

程序说明

本段程序代码用于选取多条记录进行删除时,利用“For…Next”循环及“Delete(N)”判断CheckBox(复选框)是否被按下,如果已经被按下时,则执行删除该币别信息的记录。

Currency.asp 程序段

135: <%

136: function ModifyCurrency

137:     Set OBJConn = Server.CreateObject("ADODB.Connection")

138:     OBJConn.Open "driver={microsoft access driver (*.mdb)}; dbq=" & server.mappath("db/mydb.mdb")

139:     On Error Resume Next

140:     Counters = 0

141:     for i = 0 to request.form("Values")

142:         if request.form("Modify" & i) = "on" then

143:             Counters = 1

144:             SQL = "update 币别信息 set 币别= '" & requ est.form("currency"&i) & "',

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 



打印本文 打印本文  关闭窗口 关闭窗口