Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
760 views
in Technique[技术] by (71.8m points)

sql - Error while using ExecuteNonQuery c#

I have a problem while using ExecuteNonQuery.

This is my code :

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);

And this is the error:

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'

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 .

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

Screenshot

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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.

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...