mercredi 24 juin 2015

C# error "Could not find Stored procedure" if DB collation is not “SQL_Latin1_General_CP1_CI_AS”

This is the situation that I encountered:


A) C# code: execute stored procedure "Check_Data"

  • I would like to state that there is nothing wrong with my C# code here as it is as basic as it can get, and it is also double-checked by me and my co-workers.

B) SQL Server:

  • All DBs are MSSQL2005. Please do not suggest to upgrade them, as this is what my client uses.

  • Please note that all 4 DBs below is created in the exact same way, as well as the stored procedure "Check_Data". The only difference is the collation of each DB.

  • I used user "sa" to connect to all DB to make sure that there is no problem with permission.

  • Instance A: collation “SQL_Latin1_General_CP1_CI_AS”

    • DB 1: collation “SQL_Latin1_General_CP1_CI_AS” => C# code run successful.
    • DB 2: collation “Vietnamese_CI_AS” => C# code has error "Could not find Stored procedure" .
  • Instance B: collation “Vietnamese_CI_AS”

    • DB 1: collation “SQL_Latin1_General_CP1_CI_AS” => C# code run successful.
    • DB 2: collation “Vietnamese_CI_AS” => C# code has error "Could not find Stored procedure" .

So basically, my DB just hate collation “Vietnamese_CI_AS” and refuse to get this stored procedure.

This is the script of "Check_Data":

CREATE PROCEDURE [dbo].[Check_Data]
(   
    @Acc    nvarchar(50),   
    @Status varchar(500) OUTPUT)
AS
BEGIN

if exists (select 1 from tblRequest where Acc=@Acc)

    SET @Status = '1'--have data
else
    SET @Status = '0'--have not data        
END

Could anyone tell me what is wrong with it?

Aucun commentaire:

Enregistrer un commentaire