Unanswered: Trying to open and populate an Excel sheet.
I am trying to open an Excel sheet an populate the cells with data from a MySql table. The Excel sheet opens, but then I get the error "runtime error 2147467259 Method 'Copy from Recordset' of object 'Range' failed". Here is my code:
Dim rs2 As ADODB.Recordset
Dim DB2 As New ADODB.Connection
Dim sSQL2 As String
sSQL2 = "select * from item_tracker where user_name like ('" & cmboUserList.Text & "');"
DB2.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False; UID=root@localhost ; database=mysql; option=3"
DB2.Open "data source=myodbc"
DB2.Execute ("USE Mysql;")
Set rs2 = New ADODB.Recordset
rs2.CursorType = adOpenKeyset
rs2.LockType = adLockOptimistic
rs2.CursorLocation = adUseClient
rs2.Open sSQL2, DB2, adOpenForwardOnly, adLockReadOnly, adCmdText
Dim xlApp As New Excel.Application
Dim xlBook As Workbook
Dim xlws As Worksheet
Set xlws = xlApp.ActiveSheet
Set xlBook = xlApp.Workbooks.Add
xlApp.Visible = True
Set xlws = xlBook.Worksheets("Sheet1")
Any help would be appreciated. Thank you very much for your time.
"Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
"I have my standards. They may be low, but I have them!" - Bette Middler
"It's a book about a Spanish guy named Manual. You should read it." - Dilbert