server.ConnectionContext.SqlExecutionModes =
SqlExecutionModes.CaptureSql;
Database db = server.Databases["myDatabase"];
This my code for connection for generate script but an error occur
(Failed to connect to server SERVER.) in this line
Database db = server.Databases["myDatabase"];