Hi,
Below is my code -(Excel 2013)
Sub Button1_Click()
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
Dim sSQLQry As String
Dim ReturnArray
Dim mrs As New ADODB.Recordset
Dim DBPath As String, sconnect As String
cnn.ConnectionString = "DSN=ABC_32;UID=xxx@xxx.com;PWD=xxxx;"
cnn.Open
' Find out if the attempt to connect worked.
If cnn.State = adStateOpen Then
MsgBox "Welcome to Pubs!"
Else
MsgBox "Sorry. No Pubs today."
End If
Set mrs = cnn.Execute("select rowid from schema.table where accnumber = 'ABC'")
MsgBox mrs("rowid")
ReturnArray = mrs.GetRows
Sheet1.Range("A2").CopyFromRecordset mrs
mrs.Close
' Close the connection.
cnn.Close
End Sub
From the above code I am able to get the record in Msgbox but not able to paste in a excel cells
Please let me know what I am doing wrong ?
Bookmarks