Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2003
    Posts
    2

    Unhappy Unanswered: Scripting User Defined Function using SQL-DMO throws an error

    When I use SQL-DMO library and VB to script out a User Defined Function I get an error: 0x80045339

    [SQL-DMO]Unexpected parameter value or other condition.

    I'm using the Script() method of DBObject object. No matter what flags I pass, I get the same error.

    Surprisingly, when I use the same code to script out a Stored Proc, a View or a Trigger, it works just fine.

    I'm running SQL Server 2000.

    Any suggestions would be highly appreciated.

  2. #2
    Join Date
    May 2002
    Posts
    299

    Re: Scripting User Defined Function using SQL-DMO throws an error

    In order to get access to new properties in sql2k, you must use SqlServer2/Database2 collection.
    --
    -oj
    http://www.rac4sql.net

  3. #3
    Join Date
    Feb 2003
    Posts
    2

    Re: Scripting User Defined Function using SQL-DMO throws an error

    Accessing DBObject through SQLDMO.SQLServer2 or SQLDMO.Database2 did not seem to help the problem.

    BTW, to get hold of the User Defined Function, I'm using GetObjectByName() call on the Database object. This call returns DBObject on which I call the Script() method.

  4. #4
    Join Date
    May 2002
    Posts
    299

    Re: Scripting User Defined Function using SQL-DMO throws an error

    GetObjectByName() can only reference tables and stored procedures. This is by design.

    Here is a quick demo.

    Dim oServer As New SQLDMO.SQLServer
    Dim oDatabase As SQLDMO.Database2
    Dim oUdf As SQLDMO.UserDefinedFunction
    With oServer
    .LoginSecure = True
    .Connect "(local)\dev"

    Set oDatabase = .Databases("RAC")
    For Each oUdf In oDatabase.UserDefinedFunctions
    MsgBox(oUdf.Script(SQLDMOScript_Default))
    Next oUdf

    .DisConnect
    End With
    --
    -oj
    http://www.rac4sql.net

  5. #5
    Join Date
    May 2002
    Posts
    299

    Re: Scripting User Defined Function using SQL-DMO throws an error

    GetObjectByName() can only reference tables and stored procedures. This is by design.

    Here is a quick demo.

    Dim oServer As New SQLDMO.SQLServer
    Dim oDatabase As SQLDMO.Database2
    Dim oUdf As SQLDMO.UserDefinedFunction
    With oServer
    .LoginSecure = True
    .Connect "(local)\dev"

    Set oDatabase = .Databases("RAC")
    For Each oUdf In oDatabase.UserDefinedFunctions
    MsgBox(oUdf.Script(SQLDMOScript_Default))
    Next oUdf

    .DisConnect
    End With
    --
    -oj
    http://www.rac4sql.net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •