access的表MailInfo中有mailAddress和linkMan兩個(gè)字段 添加信息的界面有txtMailAddress.Text和txtName.Text兩個(gè)變量, 輸入要改的內(nèi)容,當(dāng)txtMailAddress.Text和mailAddress相同時(shí),txtName.Text賦值給linkMan,但是表里有多條記錄的mailAddress相同,怎樣把他們的linkMan都修改呢? 我現(xiàn)在只能修改第一條記錄,后面mailAddress相同的修改不了! 滿意答案 用SQL語句可以一次性搞定,比如: set conn=createobject("adodb.connection") conn.open "....." '這里連接數(shù)據(jù)庫的過程省略了,自己改 conn.execute "update MailInfo set linkMan='" & txtName.Text & "' where mailAddress='" & txtMailAddress.Text & "'" conn.close set conn=nothing 也可以找出所有txtMailAddress.Text和mailAddress相同的記錄,然后逐條修改: set conn=createobject("adodb.connection") conn.open "....." '這里連接數(shù)據(jù)庫的過程省略了,自己改 set rs=createobject("adodb.recordset") rs.open "select * from MailInfo where mailAddress='" & txtMailAddress.Text & "'",conn,1,3 do until rs.eof rs("linkMan")=txtName.Text rs.update rs.movenext loop rs.close set rs=nothing conn.close set conn=nothing |
|