怎样能取出results = adoConnection.execute(strSQL)的第一列数据?
strSQL = "select name from accts where acct='100001'"
strConnect = "Provider=MSDAORA;" _
& "Data Source=mydatabase;" _
& "User ID=myuserid;" _
& "Password=mypassword;"
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Open strConnect
results = adoConnection.execute(strSQL)
'在此取出第一列数据,应该怎样写代码?
adoConnection.Close
[解决办法]
dim a as string
……
with results
.CursorType = adOpenStatic
.LockType = adLockReadOnly
set results = adoConnection.execute(strSQL)
if not results.eof then
a =.fields(0).value
endif
end with
[解决办法]
strSQL = "select name from accts where acct='100001'"
strConnect = "Provider=MSDAORA;" _
& "Data Source=mydatabase;" _
& "User ID=myuserid;" _
& "Password=mypassword;"
Set adoConnection = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
rs.open strsql,adoConnection
debug.print rs.fields(0).value
详细的你可以参考一下ADO的手册。