Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 未找到存储过程_C#_Sql Server_Database_Stored Procedures - Fatal编程技术网

C# 未找到存储过程

C# 未找到存储过程,c#,sql-server,database,stored-procedures,C#,Sql Server,Database,Stored Procedures,我有这段代码,用于使用Windows窗体应用程序将数据插入数据库 但是我得到了这个错误 找不到存储过程“sp_insert” 我没有使用任何外部服务器,它是本地数据库 更新:我似乎没有存储过程,所以我尝试创建一个存储过程,但它抛出了另一个错误 CREATE PROCEDURE sp_insert @UserName varchar(20), @Password varchar(18), @Email varchar(50), @Name varchar(20),

我有这段代码,用于使用Windows窗体应用程序将数据插入数据库

但是我得到了这个错误

找不到存储过程“sp_insert”

我没有使用任何外部服务器,它是本地数据库

更新:我似乎没有存储过程,所以我尝试创建一个存储过程,但它抛出了另一个错误

CREATE PROCEDURE sp_insert
    @UserName varchar(20),
    @Password varchar(18),
    @Email varchar(50),
    @Name varchar(20),
    @Surname varchar(20)
AS
    -- here the error occurs "error near syntax" but User is my table name 
    -- and it's  correct I don't know what is the problem is
    INSERT INTO User (UserName, Password, Email, Name, Surname)
    VALUES (@UserName, @Password, @Email, @Name, @Surname)
C#代码:


为什么不试试dbo.sp_insert

SqlCommand cmd = new SqlCommand("dbo.sp_insert", con);

为什么不试试dbo.sp_insert

SqlCommand cmd = new SqlCommand("dbo.sp_insert", con);

您正在使用保留字:

改变

 INSERT INTO User( UserName,Password,Email,Name,Surname)


尽量避免使用看起来会与您正在编写代码的操作系统或应用程序共享的术语。您将省去一些麻烦。

您正在使用保留字:

改变

 INSERT INTO User( UserName,Password,Email,Name,Surname)


尽量避免使用看起来会与您正在编写代码的操作系统或应用程序共享的术语。你会省去一些麻烦。

你不觉得这个错误很明显吗?在该数据库中是否有具有该名称的存储过程?作为旁注,使用sp_uu前缀命名存储过程被认为是错误的,因为您可能会与系统存储过程发生冲突names@Steve哎呀,我在贴出问题后就明白了。现在,我尝试添加一个存储过程,但它显示了一个错误您得到了什么错误?“user”是一个关键字,请更改表的名称。在此之前,您可以使用[user]。旁注:您不应该在存储过程中使用
sp_uu
前缀。微软已经这样做了,而且你确实有可能在将来的某个时候发生名称冲突。最好只是简单地避免使用
sp.
并使用其他东西作为前缀,或者根本不使用前缀!这个错误似乎很明显,你不觉得吗?在该数据库中是否有具有该名称的存储过程?作为旁注,使用sp_uu前缀命名存储过程被认为是错误的,因为您可能会与系统存储过程发生冲突names@Steve哎呀,我在贴出问题后就明白了。现在,我尝试添加一个存储过程,但它显示了一个错误您得到了什么错误?“user”是一个关键字,请更改表的名称。在此之前,您可以使用[user]。旁注:您不应该在存储过程中使用
sp_uu
前缀。微软已经这样做了,而且你确实有可能在将来的某个时候发生名称冲突。最好只是简单地避免使用
sp.
并使用其他东西作为前缀,或者根本不使用前缀!