iT邦幫忙

0

asp 資料庫不覆蓋原本資料

請問如何不覆蓋原來的資料
例如:姓名:AAA 已登入到資料庫,要再填寫姓名:AAA一次 如何讓資料庫不用覆蓋,可以新增到下一筆資料欄位,即使所有資料都一模一樣寫可以寫再下一筆,謝謝!

ps:我剛有用寫入時間不同,就可以新增下一筆一模一樣的資料(除寫入時間不同),但有更好的方法嗎?
SQL= "Select * from list where usrtime='"&usrtime&"'"

<% 

Set conn =db_connection("db/T95.mdb")


name=Request("name")
lab=Request("lab")
phone=Request("phone")


SQL= "Select * from list where name='"&name&"'"
Set rs=open_recordset(conn,sql,3,3)'資料庫,資料表
if (rs.bof and rs.eof) then
	rs.addnew
end if
rs("name")=name
rs("phone")=phone
rs("lab")=lab
rs("usrtime")=Now
rs.update
rs.close
Conn.Close

%>           

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<meta http-equiv="refresh" content="3;url=sign.asp">
<title>借鑰匙系統</title>
</head>

<body>
<p>
<p>
<table>
<tr>個人報名資料如下:</tr>
<tr>
<td>姓名:<%=name%></td>
<td>借用人聯絡電話:<%=phone%></td>
</tr>

<tr>
<td>實驗室鑰匙編號<%=lab%></td>
</tr>


<tr>
<td colspan="2" align="center">填寫完畢,將於3秒後跳回上一頁</td>
</tr>

</table>
</body>

</html>


<%

function db_connection(dbn) '建立資料庫

dim provider,db_path,ds,cns,conn

provider = "Provider = Microsoft.Jet.OLEDB.4.0; "
 
ds= "Data Source= "& server.mappath(dbn)

cns= provider&ds

set conn= server.createobject("ADODB.Connection")'連結資料庫

conn.open cns
set db_connection = conn
end function

function open_recordset(cnn,sql,cs,ltype)'從資料庫取資料

dim rs

'on error resume next

set rs= server.createobject("ADODB.Recordset")
rs.open sql,cnn,cs,ltype
set open_recordset = rs
if err.number <> 0 then
    response.write "["&SQL&"]<br>"
    response.end
end if    
end function
%>
刪除if (rs.bof and rs.eof) then
小魚 iT邦大師 1 級 ‧ 2017-11-28 12:42:29 檢舉
同感
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答