我这里的错误很少
server.ConnectionContext.ExecuteNonQuery(script);
来自此代码:
using System.IO;
using System.Windows;
using Microsoft.SqlServer.Management.Smo;
using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
namespace trycollation
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button_Click(object sender, RoutedEventArgs e)
{
string sqlConnectionString = "Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True";
FileInfo file = new FileInfo(@"C:\Users\dimitar.grudev\AppData\Local\Temp\RDBS\Satage1\TRZPro_17083118563804_step1.sql");
string script = file.OpenText().ReadToEnd();
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
}
}
}
我尝试使用此代码添加应用程序配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
但仍有相同的错误。哪里错了?
错误:
其他信息:混合模式程序集是针对版本构建的 运行时'v2.0.50727'并且无法在4.0运行时加载 没有其他配置信息。