pirmas po ranka papuoles ADO pavyzdys:
Sub Add_Results_Of_ADO_Recordset()
'This was set up using Microsoft ActiveX Data Components version 2.8
Dim cnt As ADODB.Connection
Dim rst As ADODB.Recordset
Dim stSQL As String
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Dim rnStart As Range
Const stADO As String = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"Initial Catalog=BI;" & _
"Data Source=AURDWDEV01"
'where BI is SQL Database & AURDWDEV01 is SQL Server
Set wbBook = ActiveWorkbook
Set wsSheet = wbBook.Worksheets(1)
With wsSheet
Set rnStart = .Range("A1")
End With
stSQL = "SELECT * FROM Settings"
Set cnt = New ADODB.Connection
With cnt
.CursorLocation = adUseClient
.Open stADO
.CommandTimeout = 0
Set rst = .Execute(stSQL)
End With
'Here we add the Recordset to the sheet from A1
rnStart.CopyFromRecordset rst
'Cleaning up.
rst.Close
cnt.Close
Set rst = Nothing
Set cnt = Nothing
End Sub
"Raimis" <no@mail.com> wrote in message news:gl243u$nda$1@trimpas.omnitel.net...
>
>
>>
>> Su Crystal reports padaryciau statines ataskaitas, tik nesumastau, kaip
>> vartotojams geriau duomenis is bazes i exceli traukti. Nors kaip avarinis
>> variantas butu antikinis external data importas i exceli.
>
> Ilga laika tam naudojau ms query, dabar VBA . Naudojant ADO jungiesi prie SQL serverio,
> gauni rezultata i recordset'a, o tada delioji ji excelyje kaip nori.
>
>
>