.......
Str1 = "update phoneinfo set projectname='" & TxtProjectID.Text & "',outdate={fn now()} where city='" & TxtCity.Text & "' and ID in (Select Top " & TxtTal.Text & " ID from phoneinfo)"
Conn.Execute (Str1)
.......
注:TxtTal.Text 是可输入的要更新的记录条数;ID为表phoneinfo的主键;TxtCity.text为可输入的文本框的值。
我的目的是能过输入条件来控制更新表中的记录数,而不是更新所有的记录。
现在的问题是,执行没有错误提示,但表里的记录不会更新.这句怎么啦?
Str1 = "update phoneinfo set projectname='" & TxtProjectID.Text & "',outdate={fn now()} where city='" & TxtCity.Text & "' and ID in (Select Top " & TxtTal.Text & " ID from phoneinfo)"
Conn.Execute (Str1)
.......
注:TxtTal.Text 是可输入的要更新的记录条数;ID为表phoneinfo的主键;TxtCity.text为可输入的文本框的值。
我的目的是能过输入条件来控制更新表中的记录数,而不是更新所有的记录。
现在的问题是,执行没有错误提示,但表里的记录不会更新.这句怎么啦?
你用
msgbox strl 看看,然后到SQL 查询分析器里面执行一下,试试可否?
ID in (Select Top " & TxtTal.Text & " ID from phoneinfo)
如果TxtTal.Text的值是10,那么不就是对前10条记录进行更新嘛
Str1 = "update phoneinfo set projectname='" & TxtProjectID.Text & "',outdate={fn now()} where ID in (Select Top " & TxtTal.Text & " ID from phoneinfo where city='" & TxtCity.Text & "' )"