找不到存储过程 [英] could not find the stored procedure

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

问题描述

亲爱的所有人;

我从ac#程序调用存储过程并且我一直有这样的错误消息:

'找不到存储过程sp_Trial'< br $>


C#代码如下

---------------------- -

Dear all;
I am calling a stored procedure from a c# program and I keep having this error message :
'could not find the stored procedure sp_Trial'

C# codes are as follows
-----------------------

protected void btn_Add_Click1(object sender, EventArgs e)
{

try
{

// Connection to the database
//
//
string str;
str = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
SqlConnection sqlCon = new SqlConnection(str);

// Call the stored procedure
SqlCommand sqlCmd = new SqlCommand("sp_Trial", sqlCon);
sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;

// Create and supply the output parameters
sqlCmd.Parameters.Add("@LoanID", System.Data.SqlDbType.VarChar, 10);
sqlCmd.Parameters["@LoanID"].Direction = System.Data.ParameterDirection.Output;


// Open the sql data connection
sqlCon.Open();

// Execute the stored procedure
sqlCmd.ExecuteNonQuery();

lblstatus.Text = "Student details saved successfully";

// Assign the results to the controls
txt_Int_Code.Text = sqlCmd.Parameters["@LoanID"].Value.ToString();

//
//
sqlCon.Close();

}

catch (Exception ex)
{
lblstatus.Text = ex.Message;
}



存储过程

-----------------


Stored Procedure
-----------------

USE [COC_CREDIT]
GO
/****** Object: StoredProcedure [dbo].[sp_Trial] Script Date: 05/25/2014 12:22:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


ALTER Procedure [dbo].[sp_Trial]
(
@LoanID	varchar(10) Output
)
As
Begin

Declare @SID Smallint

Select @SID = ISNULL(MAX(CONVERT(SMALLINT,SUBSTRING(INT_NO,4,6))),0) + 1 From INTEREST

Select @LoanID = 'INT' + REPLICATE('0',6 - LEN(@SID)) + CONVERT(VARCHAR(6),@SID)
End



请帮我纠正错误


Please help me to correct the error

推荐答案

检查连接字符串:然后检查它引用的数据库。您可能已将生产数据库更新为SP而不是开发DB,反之亦然。
Check your connection string: then check the database that it refers to. Chances are that you have updated the production database to have the SP and not the development DB, or vice versa.


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

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