What's wrong with my SMO C# tiny program?

  • I want to script SQL Server objects programmatically [say, delete (DROP) all FKs, then change keys, and restore (CREATE) FKs] with SMO Scripter class.

    I found an article on the Web, but...

    Please see the attached image and help me to compile ~20 line long C# program.

    Thanks.

    PS: I am not exactly 'Rookie' but SQL Server is just one of my development environments.

  • you need to instantiate the Urn[] collection before attempting to use it.

    Revise the following

    StringCollection sc = scripter.Script(new Urn[] {db.Urn });

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • In my understsnding of the quoted code it means (shortly) the following:

  • Create (instantiate) a new Collection of Urm objects connsisting of one member
  • Assign this only member a specified db.Urn
  • Pass initialized collection to Script() method
  • Put its result reference into sc variable
  • What's wrong with omelette instantiation?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply