Dim rs As New ADODB.Recordset '定义记录集
Dim conn As New ADODB.Connection '定义数据连接
Dim i As Integer
Private Sub CommandButton1_Click()
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.Open "Provider=MSDAORA.1;Password=ynsoft;User ID=system;Data Source=ORCL;Persist Security Info=True"
'rs.Open "insert into dyfcammeter t (t.no,t.zx311) values(116,2)", conn, adOpenStatic, adLockOptimistic
rs.Open "select * from dyfcammeter t order by t.no desc", conn, adOpenStatic, adLockOptimistic
Cells.Clear
For i = 0 To rs.Fields.Count - 1
Cells(1, i + 1) = rs.Fields(i).Name
Next i
Range("a2").CopyFromRecordset rs
Cells.Columns.AutoFit
rs.Close
End Sub
Dim conn As New ADODB.Connection '定义数据连接
Dim i As Integer
Private Sub CommandButton1_Click()
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.Open "Provider=MSDAORA.1;Password=ynsoft;User ID=system;Data Source=ORCL;Persist Security Info=True"
'rs.Open "insert into dyfcammeter t (t.no,t.zx311) values(116,2)", conn, adOpenStatic, adLockOptimistic
rs.Open "select * from dyfcammeter t order by t.no desc", conn, adOpenStatic, adLockOptimistic
Cells.Clear
For i = 0 To rs.Fields.Count - 1
Cells(1, i + 1) = rs.Fields(i).Name
Next i
Range("a2").CopyFromRecordset rs
Cells.Columns.AutoFit
rs.Close
End Sub