Question : Microsoft.sqlserver.management .net 4 help

good day, the following code works in .net 3.5; however, i really need to execute scripts in .net 4.

unfortunately, the code doesn't work in 4 - anyone know of a workaround that i can use?

the scripts have numerous "go" statements - the code below executes it fine.

any help is appreciated.   thanks.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
using System.Data.SqlClient;
using Microsoft.SqlServer;
using Microsoft.SqlServer.Management;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using System.IO;


        public static void run(string script)
        {
            try
            {
                using (SqlConnection c = new SqlConnection(decryptedConnectionstring))
                {
                    c.Open();
                    ServerConnection connection = new ServerConnection(c);
                    Microsoft.SqlServer.Management.Smo.Server server = new Server(connection);
                    try
                    {
                        server.ConnectionContext.ExecuteNonQuery(script);
                    }
                    catch (Exception ex)
                    {
				'	custom err catching
                    }
                }

            }
            catch (Exception ex)
            {
				'	custom err catching
            }
        }
    }
}

Answer : Microsoft.sqlserver.management .net 4 help

Random Solutions  
 
programming4us programming4us