Visual Studio | “无法找到”现有的“存储过程” [英] Visual Studio | "Unable to find" existing "Stored Procedure"

查看:122
本文介绍了Visual Studio | “无法找到”现有的“存储过程”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

描述

所以我的数据库有两个存储过程。第一个(插入数据) -  

So I have two stored procedures for my Database. The first one (which inserts data) - 

dbo.InsertDetails

工作正常,第二个存储程序 - " dbo.remove_details " - (删除数据库中的数据)显然不存在,尽管它在我的SQL Server Manager应用程序中是正确的。

works fine, the second stored procedure - "dbo.remove_details" - (which deletes the data from my database) apparently doesn't exist despite it being right in my SQL Server Manager Application.

为什么它找不到第二个存储过程但它可以找到第一个?

Why can't it find the second Stored procedure but it can find the first?

当前代码

stormconn.Open();
                SqlCommand cmd = new SqlCommand("EXEC dbo.remove_details @Fullname, @Address, @Email, @PostCode, @Tel", stormconn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Fullname", TextBox1.Text);
                cmd.Parameters.AddWithValue("@Address", TextBox2.Text);
                cmd.Parameters.AddWithValue("@Email", TextBox3.Text);
                cmd.Parameters.AddWithValue("@PostCode", TextBox4.Text);
                cmd.Parameters.AddWithValue("@Tel", TextBox5.Text);
                cmd.ExecuteNonQuery();
                stormconn.Close();


截图/图片/插图

N / A

我尝试过的东西

检查存储过程名称的拼写。

Checked the spelling of the name of the stored procedure.

调试/诊断消息

Debug/Diagnostic Messages

System.Data.SqlClient.SqlException: 'Could not find stored procedure 'EXEC dbo.remove_details @Fullname, @Address, @Email, @PostCode, @Tel'.'




附加信息

除了我开始这个软件是一个完整的笑话。

Nothing other than I'm beginning to this this software is a complete joke.

使用的软件+版本

Microsoft SQL Server Management Studio        14.0.17289.0

Microsoft Analysis Services客户端工具       14.0.1016.283

Microsoft Data访问组件(MDAC)       10.0.17134.1

Microsoft MSXML       3.0 4.0 6.0

Microsoft Internet Explorer       9.11.17134.0

Microsoft .NET Framework       4.0.30319.42000

操作系统       6.3.17134

Microsoft SQL Server Management Studio      14.0.17289.0
Microsoft Analysis Services Client Tools      14.0.1016.283
Microsoft Data Access Components (MDAC)      10.0.17134.1
Microsoft MSXML      3.0 4.0 6.0
Microsoft Internet Explorer      9.11.17134.0
Microsoft .NET Framework      4.0.30319.42000
Operating System      6.3.17134

Microsoft Visual Studio Community 2017

版本15.9.6

VisualStudio.15.Release / 15.9.6 + 28307.344

Microsoft .NET Framework

版本4.7.03056
Microsoft Visual Studio Community 2017
Version 15.9.6
VisualStudio.15.Release/15.9.6+28307.344
Microsoft .NET Framework
Version 4.7.03056

推荐答案

嗨托德,

摆脱EXEC d SqlCommand中的参数。它应该是这样的:

Get rid of the EXEC and the parameters in the SqlCommand. It should be like this:

stormconn.Open();
SqlCommand cmd = new SqlCommand("dbo.remove_details", stormconn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Fullname", TextBox1.Text);
cmd.Parameters.AddWithValue("@Address", TextBox2.Text);
cmd.Parameters.AddWithValue("@Email", TextBox3.Text);
cmd.Parameters.AddWithValue("@PostCode", TextBox4.Text);
cmd.Parameters.AddWithValue("@Tel", TextBox5.Text);
cmd.ExecuteNonQuery();
stormconn.Close();





这篇关于Visual Studio | “无法找到”现有的“存储过程”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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