create storedproc with smo

hi,
i try to create storeproc with smo but i 've an exception
"Create failed for StoredProcedure 'dbo.TEST'"
{"Cannot create StoredProcedure '[dbo].[TEST]' if parent is not yet created."}
but sp.parent is created
please help me

attache my work
StoredProcedure sp = new StoredProcedure();
sp.Schema = "dbo";
sp.Name = "TEST";
sp.Parent = new Database(new Server("serveur"), "db_TEST");
sp.IgnoreForScripting = false;
sp.TextMode = false;
sp.ImplementationType = ImplementationType.TransactSql;

sp.Parameters.Add(new StoredProcedureParameter(sp,"@toto, DataType.DateTime));


sp.TextBody = "Select 1";
sp.Create();

[708 byte] By [casimir] at [2008-1-28]
# 1
You need to create the database first before creating the SP.

Database db = new Database(new Server(), "db_TEST");

db.Create();

StoredProcedure sp = new StoredProcedure();

sp.Schema = "dbo";

sp.Name = "TEST";

sp.Parent = db;

sp.TextMode = false;

sp.ImplementationType = ImplementationType.TransactSql;

sp.Parameters.Add(new StoredProcedureParameter(sp, "@toto", DataType.DateTime));

sp.TextBody = "Select 1";

sp.Create();

Runamuk at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...

SQL Server

Site Classified