Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Copy an array into an ADO recordset?

I have the following function in which I am attempting to copy an array into
an ADO recordset directly from the current sheet in Excel. This generates an
error. Can this even be done? If so, how? Can someone please correct my
function?

Private Function ADOCopyArrayIntoRecordset(argArray As Variant) As
ADODB.Recordset
Dim rsADO As Object
Dim lngR As Long
Dim lngC As Long
Set rsADO = CreateObject("ADODB.Recordset.2.8")
For lngR = 1 To UBound(argArray, 1)
For lngC = 1 To UBound(argArray, 2)
rsADO.Fields(lngC - 1).Value = argArray(lngR, lngC)
Next lngC
rsADO.MoveNext
Next lngR
End Function

Thanks much in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Copy an array into an ADO recordset?


"quartz" wrote in message
...
I have the following function in which I am attempting to copy an array

into
an ADO recordset directly from the current sheet in Excel. This generates

an
error. Can this even be done? If so, how? Can someone please correct my
function?

Private Function ADOCopyArrayIntoRecordset(argArray As Variant) As
ADODB.Recordset
Dim rsADO As Object
Dim lngR As Long
Dim lngC As Long
Set rsADO = CreateObject("ADODB.Recordset.2.8")
For lngR = 1 To UBound(argArray, 1)
For lngC = 1 To UBound(argArray, 2)
rsADO.Fields(lngC - 1).Value = argArray(lngR, lngC)
Next lngC
rsADO.MoveNext
Next lngR
End Function

Thanks much in advance.


I think you should use Set rsADO = CreateObject("ADODB.Recordset")
Do you get an error message?

/Fredrik


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Copy an array into an ADO recordset?


"quartz" wrote in message
...
I have the following function in which I am attempting to copy an array

into
an ADO recordset directly from the current sheet in Excel. This generates

an
error. Can this even be done? If so, how? Can someone please correct my
function?

Private Function ADOCopyArrayIntoRecordset(argArray As Variant) As
ADODB.Recordset
Dim rsADO As Object
Dim lngR As Long
Dim lngC As Long
Set rsADO = CreateObject("ADODB.Recordset.2.8")
For lngR = 1 To UBound(argArray, 1)
For lngC = 1 To UBound(argArray, 2)
rsADO.Fields(lngC - 1).Value = argArray(lngR, lngC)
Next lngC
rsADO.MoveNext
Next lngR
End Function

Thanks much in advance.


I think the code should be something like this

Private Function ADOCopyArrayIntoRecordset(argArray As Variant) As
ADODB.Recordset
Dim rsADO As Object
Dim lngR As Long
Dim lngC As Long
Set rsADO = CreateObject("ADODB.Recordset")
For lngR = 1 To UBound(argArray, 1)
rsADO.AddNew
For lngC = 1 To UBound(argArray, 2)
rsADO.Fields(lngC - 1).Value = argArray(lngR, lngC)
Next lngC
Next lngR
Set ADOCopyArrayIntoRecordset = rsADO
End Function


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default fixed object will be move

i insert filter in my worksheet, and i made to each cell hyperlink the
problem is when i select items from filter appear to me this message (fixed
object will move)

"Fredrik Wahlgren" wrote:


"quartz" wrote in message
...
I have the following function in which I am attempting to copy an array

into
an ADO recordset directly from the current sheet in Excel. This generates

an
error. Can this even be done? If so, how? Can someone please correct my
function?

Private Function ADOCopyArrayIntoRecordset(argArray As Variant) As
ADODB.Recordset
Dim rsADO As Object
Dim lngR As Long
Dim lngC As Long
Set rsADO = CreateObject("ADODB.Recordset.2.8")
For lngR = 1 To UBound(argArray, 1)
For lngC = 1 To UBound(argArray, 2)
rsADO.Fields(lngC - 1).Value = argArray(lngR, lngC)
Next lngC
rsADO.MoveNext
Next lngR
End Function

Thanks much in advance.


I think the code should be something like this

Private Function ADOCopyArrayIntoRecordset(argArray As Variant) As
ADODB.Recordset
Dim rsADO As Object
Dim lngR As Long
Dim lngC As Long
Set rsADO = CreateObject("ADODB.Recordset")
For lngR = 1 To UBound(argArray, 1)
rsADO.AddNew
For lngC = 1 To UBound(argArray, 2)
rsADO.Fields(lngC - 1).Value = argArray(lngR, lngC)
Next lngC
Next lngR
Set ADOCopyArrayIntoRecordset = rsADO
End Function



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset Filter by Array Kou Vang[_2_] Excel Programming 0 February 1st 05 04:31 PM
Passing an array or recordset to a stored procedure Paul Robinson Excel Programming 1 December 2nd 04 05:15 AM
Passing an array or recordset to a stored procedure Robin Hammond[_2_] Excel Programming 1 December 2nd 04 05:15 AM
Passing an array or recordset to a stored procedure Jamie Collins Excel Programming 1 December 2nd 04 05:15 AM
Copy Recordset into array? Andrew_blue Excel Programming 2 May 6th 04 07:23 PM


All times are GMT +1. The time now is 11:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"