How do you add object to a collection 
Author Message
 How do you add object to a collection

I wrote this code to attach SQL7 database files to another computer running
SQL7 in the MSDE environment.  However, when I run it, this is what I get:

[SQL-DMO]This property or method is not available until the object (or its
parent, if applicable) has been added to a collection.  What does it all
mean and how can I attach the file to a collection?

Option Explicit
Dim oSvroot As Object
Dim dataFileMember As String
Dim dataLogMember As String
Dim dbName As String    'name of database

Private Sub cmdAttach_Click()

' Attach.
Call oSvroot.AttachDB(dbName, dataFileMember & ", " & dataLogMember)

End Sub

Private Sub Form_Load()

Set oSvroot = CreateObject("SQLDMO.SQLServer")

dataFileMember = App.Path & "\OutReachSQL.MDF"
dataLogMember = App.Path & "\OutReachSQL.LDF"
dbName = "KIDFISH"

End Sub

Public Function AttachDatabase(dbName As String, FileName1 As String,
Filename2 As String) As Boolean
' Connect.
oSvroot.Connect "(local)", "sa", ""

End Function



Wed, 29 May 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. ? Collection add object -> usercontrol add control

2. ? Collection add object -> usercontrol add control

3. Adding objects to a collection object

4. Adding to Collection Object

5. More on Adding a class object to collections

6. Adding user defined types to a collection object

7. Adding objects to collections

8. VB5.0 Type mismatch when adding object to collection

9. Storing objects added to a collection in a database

10. Adding Objects to Collections

11. Adding User-Defined Type to a Collection Object

12. Collection.Add and Collection.Item question?

 

 
Powered by phpBB® Forum Software