vb6.0如何修改sqlserver表中数据

来源:百度知道 编辑:UC知道 时间:2024/06/02 17:14:34
sql: 表aa(a,b,c)
vb: text1,text2,text3,command1

要修改a字段 a=text1
修改条件 where b=text2 and c=text3
求详细代码

能用追加10分

两种方法:
设定数据库联接为 cn ,记录集为 rs
1.
rs.find "b='"& text2.text &"' And c = '"& text3.text &"'"
if rs.eof =False then
rs![a] = text1.text
rs.update
这只对单条记录做修改。
2.
cn.Execute("Update aa Set a = '"& text1.text &"' Where b='"& text2.text &"' And c = '"& text3.text &"'")
这用于刷新所有符合条件数据。
1 禁忌比较多,2 用的比较广。