I'm writing this code:
string sqlConnectionString = conn1;
//string sqlConnectionString = "Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True";
FileInfo file = new FileInfo("d:\\behzadBULK.sql");
string script = file.OpenText().ReadToEnd();
SqlConnection conn = new SqlConnection(sqlConnectionString);
Microsoft.SqlServer.Server server = new Microsoft.SqlServer.Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
but I'm getting an error in this line
Microsoft.SqlServer.Server = ....
I added the Microsoft.SqlServer.Smo
reference, but I get this error:
'Microsoft.SqlServer.Server' is a 'namespace' but is used like a 'type'
What happen? Thanks.
My error: