Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem creating default column using DMO
Message
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
Problem creating default column using DMO
Divers
Thread ID:
01050892
Message ID:
01050892
Vues:
74
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform