在C#中找不到存储过程 [英] Can't find Stored Procedure in C#

查看:709
本文介绍了在C#中找不到存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中有以下代码...

SqlConnection thisConnection =新的SqlConnection(@网络库= DBMSSOCN;数据源= AZ;数据库= FMS;用户ID = fms;密码=密码;");

SqlCommand thisCommand =新的SqlCommand("D:\\ SP \\ GetReport.SQL",thisConnection);

thisCommand.CommandType = CommandType.StoredProcedure;

试试
{
thisConnection.Open();
SqlDataReader thisReader = thisCommand.ExecuteReader();

...
}


当我运行时–"thisCommand.ExecuteReader引发一个异常,指出:

找不到存储过程-''D:\ SP \ GetReport.SQL''"

至今-我知道文件位于"SP"目录中!

任何建议/帮助???

在此先感谢...

N

I have the following code in C# ...

SqlConnection thisConnection = new SqlConnection(@"Network Library=DBMSSOCN;Data Source=AZ;database=FMS;User id=fms;Password=password;");

SqlCommand thisCommand = new SqlCommand("D:\\SP\\GetReport.SQL", thisConnection);

thisCommand.CommandType = CommandType.StoredProcedure;

try
{
thisConnection.Open();
SqlDataReader thisReader = thisCommand.ExecuteReader();

...
}


When I run -- the "thisCommand.ExecuteReader throws an exception that states:

"Could Not Find Stored Procedure - ''D:\SP\GetReport.SQL'' "

YET - I KNOW THE FILE IS IN THE ''SP'' DIRECTORY!

Any advice/help ???

Thanks in advance ...

N

推荐答案

那不是它的工作方式.您认为SQL Server从文件系统读取存储的proc吗?存储的proc需要存储在数据库中,然后指定GetReport或任何proc调用的名称,而无需使用其他正在使用的东西.
That''s not how it works. You thnk SQL Server reads stored procs from your file system ? The stored proc needs to be in the database, then you specify GetReport, or whatever the proc is called, without the other stuff you are using now.


这篇关于在C#中找不到存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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