Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem creating default column using DMO
Message
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Problem creating default column using DMO
Miscellaneous
Thread ID:
01050892
Message ID:
01050892
Views:
71
Hi

I wonder if anybody could help me out here ;

I have a foxpro routine which works fine under SQL server 2000, but when I run it aganst a newly installed version of SQL server 2005 Developers Edition Beta 2 I get a problem when I attempt to add a column default.

Here's the code
oSQLServer = CREATEOBJECT("SQLDMO.SQLServer")
oSQLServer.Connect(".","userid","password")

dmoDatabase = CreateObject("SQLDMO.Database2")
dmoDBFile   = CreateObject("SQLDMO.DBFile")
dmoLogFile  = CreateObject("SQLDMO.LogFile")

dmoDatabase.NAME = "Test DataBase"
dmoDatabase.collation = "SQL_Latin1_General_CP1_CI_AS"

dmoDBFile.NAME = "Test DataBase"
dmoDBFile.PhysicalName = "C:\TEST.mdf"
dmoDBFile.PrimaryFile = .T.
dmoDatabase.FileGroups("PRIMARY").DBFiles.ADD(dmoDBFile)

dmoLogFile.Name = "TEST.log"
dmoLogFile.PhysicalName = "C:\TEST.ldf"
dmoDatabase.TransactionLog.LogFiles.ADD(dmoLogFile)

oSQLServer.DATABASES.ADD(dmoDatabase)

* now add the default

dmoDefault = CreateObject("SQLDMO.Default")
dmoDefault.Name = 'UW_ZeroDefault'
dmoDefault.Text = '0'
dmoDatabase.Defaults.Add(dmoDefault) && error occurs here!
dmoDefault = .F.
when the code reaches the ADD(DmoDefault) line it errors out with a :
OLE IDispatch exception code 207 from Microsoft SQL-DMO (ODBC SQLState 42s22) 

"Invalid Column name 'id'."
Has anybody got any ideas what this could be, again this works fine under sql server 2000.

Thanks, Bernard
Next
Reply
Map
View

Click here to load this message in the networking platform