使用ExecuteNonQuery C#时出错 [英] Error while using ExecuteNonQuery c#

查看:338
本文介绍了使用ExecuteNonQuery C#时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ExecuteNonQuery时遇到问题.

这是我的代码:

var connString = @"Data Source=serwer01;Initial Catalog=PolsatCyfrowy;Integrated Security=True";

FileInfo file = new FileInfo("C:\\Users\\azbudniewek\\source\\repos\\UM2 V2\\UM2 V2\\scripts.sql");
string script = file.OpenText().ReadToEnd();

SqlConnection conn = new SqlConnection(connString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);

这是错误:

System.IO.FileNotFoundException:无法加载文件或设置"Microsoft.SqlServer.BatchParser,版本= 14.100.0.0,区域性=中性,PublicKeyToken = 89845dcd8080cc91".该文件无法下载.
文件名:'Microsoft.SqlServer.BatchParser,版本= 14.100.0.0,文化=中性,PublicKeyToken = 89845dcd8080cc91'

System.IO.FileNotFoundException: The file or set 'Microsoft.SqlServer.BatchParser, version = 14.100.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91' or one of its company can not be loaded. The file can not be downloaded.
File name: 'Microsoft.SqlServer.BatchParser, version = 14.100.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91'

(RuntimeAssembly集,字符串名称,布尔throwOnError,布尔ignoreCase,ObjectHandleOnStack)
在System.Reflection.RuntimeAssembly.GetType中(字符串名称,布尔throwOnError,布尔ignoreCase)

in System.Reflection.RuntimeAssembly.GetType (RuntimeAssembly set, string name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack)
in System.Reflection.RuntimeAssembly.GetType (string name, Boolean throwOnError, Boolean ignoreCase)

我读了很多有问题的解决方案,但无能为力.

I read a lot of solutions with problem but can't do anything .

我应该只安装另一个SQL Server吗?我已经在计算机上安装了SQL Server 2014,并且程序集所在的文件夹如下所示:

Should I just install another SQL Server? I have installed SQL Server 2014 on my computer and folder with assembly looks like this:

截图

我应该怎么做才能避免这个问题?我想我的程序集文件夹中应该有版本14.100.0.0,但不知道如何更新它.也许有人知道吗?

What should I do to avoid this problem? I think I should have version 14.100.0.0 in my assembly folder but don't know how to update it. Maybe anyone know it?

推荐答案

我遇到了类似的问题.我有一个使用Microsoft.SqlServer.SqlManagementObjects nuget包的SMO应用程序.

I had a similar issue. I have an SMO application which uses the Microsoft.SqlServer.SqlManagementObjects nuget package.

该应用程序均可在我的PC上完美运行,但是在部署它并在我们的应用程序服务器上运行时,却出现了错误.

The app all runs perfectly on my p.c however when it came to deploying it and running it on our app server i was getting the error.

无法加载文件或程序集"Microsoft.SqlServer.BatchParser.dll"或其依赖项之一.找不到指定的模块.

Could not load file or assembly 'Microsoft.SqlServer.BatchParser.dll' or one of its dependencies. The specified module could not be found.

要解决此问题,我需要再次针对x86平台构建项目.

To fix the issue I needed to build the project again targeting x86 platform.

这篇关于使用ExecuteNonQuery C#时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆