I have created a record set from Excel data, but I am not able to select the record set and insert the data into the database:
Sub insrt()
        Dim xlXML             As Object
        Dim adoRecordset      As Recordset
        Dim rng               As Range
Dim Conn_lyr
Dim ConnString_lyr
Dim Vsql_lyr As String
   Range("B6").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
        Set rng = Selection
        Set adoRecordset = CreateObject("ADODB.Recordset")
        Set xlXML = CreateObject("MSXML2.DOMDocument")
        xlXML.LoadXML rng.Value(xlRangeValueMSPersistXML)
        adoRecordset.Open xlXML
ConnString_lyr = "DRIVER={SQL Server Native Client 11.0}; SERVER=xxxxxxxx;UID=xxxxxxx;PWD=xxxxxxx;"
Set Conn_lyr = CreateObject("ADODB.Connection")
Vsql_lyr = "insert into " + Range("E1").Value + ".DBO." + Range("f1").Value + " select * from adoRecordset"
With Conn_lyr
.ConnectionString = ConnString_lyr
.Open
.Execute (Vsql_lyr)
End With
Conn_lyr.Close
Set Conn8 = Nothing
End Sub
 
    