¤ Hi,
¤ Please help!
¤ I'm trying to export data from MS SQL in Visual Basic project.
¤ Is there any similar command as in MS Access - DoCmd.TransferSpreadsheet -
¤ that can do the action to export to Excel spreadsheet? Or any method can be
¤ used in VB?
How about using SQL?
Dim cnn As New ADODB.Connection
Dim strSQL As String
cnn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\Book200.xls;Extended Properties=Excel 8.0;"
strSQL = "SELECT * INTO [Orders] FROM [Orders] IN '' [ODBC;Driver={SQL
Server};Server=(local);Database=Northwind;Trusted_Connection=yes];"
cnn.Execute strSQL
cnn.Close
Set cnn = Nothing
Paul
~~~~
Microsoft MVP (Visual Basic)