Mightyginger
Programmer
I have some code (using ADO) which queries a database and then dumps the results to a range. Fair enough, usual story. Is there an easy way instead to declare an variant and set the result from the database to that variant.
Existing code
Set sqlRs = New ADODB.Recordset
sqlCmd.CommandText = "SELECT bf.ISIN,ts.Value FROM TSeriesLookup tsl,TSeries ts,BondDefs bf WHERE ts.Id=tsl.Id AND tsl.NWCode=bf.BondCode AND ts.TradeDate='" & strMonth & "' AND (tsl.NWCode LIKE 'G_D_EUR%' OR tsl.NWCode LIKE 'G_D_GRD%') AND tsl.ValueType='MTedSpread' AND bf.ISIN <> '' ORDER BY bf.ISIN"
Set sqlRs = sqlCmd.Execute
Sheets("Output_Data"
.Cells(6, 2).CopyFromRecordset sqlRs
Could I have something like this e.g.
dim output_data_array() as variant
output_data_array.CopyFromRecordset sqlRs
this doesn't work though. Any idea guys?
Thanks for your help once again by the way!
Neil.
Existing code
Set sqlRs = New ADODB.Recordset
sqlCmd.CommandText = "SELECT bf.ISIN,ts.Value FROM TSeriesLookup tsl,TSeries ts,BondDefs bf WHERE ts.Id=tsl.Id AND tsl.NWCode=bf.BondCode AND ts.TradeDate='" & strMonth & "' AND (tsl.NWCode LIKE 'G_D_EUR%' OR tsl.NWCode LIKE 'G_D_GRD%') AND tsl.ValueType='MTedSpread' AND bf.ISIN <> '' ORDER BY bf.ISIN"
Set sqlRs = sqlCmd.Execute
Sheets("Output_Data"
Could I have something like this e.g.
dim output_data_array() as variant
output_data_array.CopyFromRecordset sqlRs
this doesn't work though. Any idea guys?
Thanks for your help once again by the way!
Neil.