应该把记录集(比如Public rss As ADODB.Recordset)要定义成全局 然后你试试Leftie的方法,试试吧,我有不懂跟一贴。
Leftie(左手,为人民币服务)请在VB里能用SQL的语句????```
Leftie(左手,为人民币服务)请问在VB里能使用SQL的语句????```
在工程中引用ADO private sub form1_load() dim conn as adodb.connection dim strsql as string with conn If .state = adStateOpen Then .Close .ConnectionString = "driver=SQL Server;server=计算机机名或IP地址;uid=sa;pwd=;database=数据库名" .CommandTimeout = 300 .Open end withstrsql="update b set b.num=a.num from a,b where a.id=b.id " conn.execute strsqlconn.close set conn=nothing end sub
from a,b
where a.id=b.id
然后你试试Leftie的方法,试试吧,我有不懂跟一贴。
private sub form1_load()
dim conn as adodb.connection
dim strsql as string
with conn
If .state = adStateOpen Then .Close
.ConnectionString = "driver=SQL Server;server=计算机机名或IP地址;uid=sa;pwd=;database=数据库名"
.CommandTimeout = 300
.Open
end withstrsql="update b set b.num=a.num from a,b where a.id=b.id "
conn.execute strsqlconn.close
set conn=nothing
end sub
Leftie(左手,为人民币服务) 的回答很精彩!