Query output into a worksheet

I

itsyash

I am using the following code to get data into RecSet from my
database. I want to know if there is a way where i can export all
records into a sheet without having to specify fields.

If that is not possible then what's the easiest way to do this?


Sub ExtractRecords()
Dim dbConn As Object
Dim SQLExtract As String
Dim RecSet As New ADODB.Recordset


Set dbConn = CreateObject("ADODB.Connection")
dbConn.Open "Driver={SQL Server};
Server=BALAJI;Database=PNR_Log;Uid=sa; Pwd=sa;"


SQLExtract = "select * from PNRData"
RecSet.Open SQLExtract, dbConn, adOpenDynamic, adLockOptimistic
dbConn.Close
Set dbConn = Nothing
End Sub


Thanks,
Yash
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top