Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 SQLDMO Scripting Problem

Author  Topic 

gbeltrao
Starting Member

2 Posts

Posted - 2007-03-09 : 11:27:00
I tried to implement the code SQL Team provided for the SQLDMO intro but it isn't working. I am getting 2 error messages for the following Function I'm implementing:

' --------- Function
Private Function ScriptTable(ByVal tableName As String, _
ByVal dbName As String, _
ByVal connStr As String) As String

Dim objDMO As SQLServer2
objDMO = New SQLDMO.SQLServer
objDMO.LoginSecure = True
objDMO.Connect(connStr)

Dim objDB As Database2

objDB = objDMO.Databases(dbName) '<-- Error 1 is here

Dim oTable As Table
oTable = objDB.Tables(tableName) '<-- Error 2 is here

Return oTable.Script()

End Function
' --------- End of Function

' Error 1: Interface 'SQLDMO.Databases' cannot be indexed because it has no default property.

' Error 2: Interface 'SQLDMO.Tables' cannot be indexed because it has no default property.

I noticed that objDMO.Databases and objDMO.Tables have no arguments so it cannot be implemented as stated in your article. Maybe my SQLDMO.dll file is outdated (I am using SQL Server 2000). Any clue, anyone?

TIA!

gbeltrao
Starting Member

2 Posts

Posted - 2007-03-09 : 12:53:13
I found the solution!
It looks that the example given by SQL Team was in VB6 so the syntax for VB.NET should be:

objDB = objDMO.Databases.Item(dbName)
and
oTable = objDB.Tables.Item(tableName)

Respectively.

Hope it'll help someone!
quote:
Originally posted by gbeltrao

I tried to implement the code SQL Team provided for the SQLDMO intro but it isn't working. I am getting 2 error messages for the following Function I'm implementing:

' --------- Function
Private Function ScriptTable(ByVal tableName As String, _
ByVal dbName As String, _
ByVal connStr As String) As String

Dim objDMO As SQLServer2
objDMO = New SQLDMO.SQLServer
objDMO.LoginSecure = True
objDMO.Connect(connStr)

Dim objDB As Database2

objDB = objDMO.Databases(dbName) '<-- Error 1 is here

Dim oTable As Table
oTable = objDB.Tables(tableName) '<-- Error 2 is here

Return oTable.Script()

End Function
' --------- End of Function

' Error 1: Interface 'SQLDMO.Databases' cannot be indexed because it has no default property.

' Error 2: Interface 'SQLDMO.Tables' cannot be indexed because it has no default property.

I noticed that objDMO.Databases and objDMO.Tables have no arguments so it cannot be implemented as stated in your article. Maybe my SQLDMO.dll file is outdated (I am using SQL Server 2000). Any clue, anyone?

TIA!

Go to Top of Page
   

- Advertisement -