create table t(
id int,
col1 int,
col2 int
)
insert into t values(1,12,45)
insert into t values(2,2,10)
insert into t values(3,13,21)
insert into t values(4,43,64)
insert into t values(5,99,74)
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
con.Open "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=myData;User ID=sa;Password=admin;"
rs.CursorLocation = adUseClient
rs.Open "select (sum(col1)-sum(col2)) as col from t", con, adOpenKeyset, adLockPessimistic, adCmdText
If rs.RecordCount > 0 Then
Set Text1.DataSource = rs
Text1.Text = rs.Fields(0).Value
End If
测试成功.