Scripting User Defined Function using SQL-DMO throws an error

Scripting User Defined Function using SQL-DMO throws an error

Post by Albert Kurlan » Thu, 27 Feb 2003 03:52:06



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.

 
 
 

Scripting User Defined Function using SQL-DMO throws an error

Post by Aaron Bertrand [MVP » Thu, 27 Feb 2003 04:05:11


Maybe you could show your code???

--
Aaron Bertrand, SQL Server MVP
http://www.aspfaq.com/

Please reply in the newsgroups, but if you absolutely
must reply via e-mail, please take out the TRASH.


Quote:> 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.


 
 
 

Scripting User Defined Function using SQL-DMO throws an error

Post by oj » Thu, 27 Feb 2003 04:24:33


Here is the same answer I gave you on dbforums.

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


Quote:> 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.

 
 
 

1. Using SQLDMO to script User Defined Functions

Hey all,

I've created a small database scripting utility which uses SQLDMO to
generate database scripts in the format i need them. However, I can't seem
to get the scripting of User Defined Functions to work, although having
tried a huge amount of more or less likely-to-work combinations of the enums
taken as arguments by the DBObject.Script() method. I continiously get the
error

Run-time error '-2147200199 (80045339)':
[SQL-DMO]Unexpected parameter value or other condition

Scripting of all other objects work just fine. I tried KB without results,
only som references to some SQL Server 7 issues. I run SQL Server 2000, SP2.
Does anybody have a clue on what to do?

2. BDE Error with TMemoField

3. call a user defined function from another user-defined function

4. Installation of SP2

5. SQL-DMO where is User Defined Functions collection?

6. Free embedded jdbc database

7. user defined function - error converting data type when used in a view

8. codepage error when restoring

9. Strange error using a user defined function to return a string

10. User Defined Function Error when using varchar

11. SQL DMO table.Script or table2.Script Function

12. User-defined error when the user doesn't define any errors

13. Using SQL 2K User-defined functions