Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / October 2003



Tip: Looking for answers? Try searching our database.

Creating Recordset from an ARRAY

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Abhi - 31 Oct 2003 16:13 GMT
How do I create a recordset from an Array.
I tried appending fields to teh recordset, then tried adding new records.
Something is missing somewhere, it doenst' work.
Any clues ?
Thomas Mobley - 31 Oct 2003 20:01 GMT
Dim arrMyArray(2, 2) As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Fields.Append "fieldname1", adVarChar, 20
rs.Fields.Append "fieldname2", adInteger
rs.Open
arrMyArray(0, 0) = "Test" & 1
arrMyArray(1, 0) = "Test" & 2
arrMyArray(0, 1) = 1
arrMyArray(1, 1) = 2
rs.AddNew
rs!fieldname1 = arrMyArray(0, 0)
rs!fieldname2 = arrMyArray(0, 1)
rs.AddNew
rs!fieldname1 = arrMyArray(1, 0)
rs!fieldname2 = arrMyArray(1, 1)
rs.MoveFirst
For x = 0 To rs.RecordCount - 1
   Debug.Print rs(0) & ", " & rs(1)
   rs.MoveNext
Next

> How do I create a recordset from an Array.
> I tried appending fields to teh recordset, then tried adding new records.
> Something is missing somewhere, it doenst' work.
> Any clues ?
Dee Payton - 31 Oct 2003 21:00 GMT
Dim iFor as long
Dim SArray()
Dim rstRecordset as NEW ADODB.Recordset

'Create Connection to database.
'Open Recordset..
'Loop to create Recordset

For iFor 0 to UBound(sArray)
      rstRecordset.AddNew
      rstRecordset.fields("MyField") = sArray(iFor)
      rstRecordset.Update
next
Set rstRecordset = nothing
Set adoConnection = nothing
Signature

DEE PAYTON

> How do I create a recordset from an Array.
> I tried appending fields to teh recordset, then tried adding new records.
> Something is missing somewhere, it doenst' work.
> Any clues ?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.