我收到此错误:
System.Data.SqlClient.SqlException:错误,因为1”
尝试从SQL调用存储过程时。
我也尝试过更改程序的调用方式,但仍然存在相同的错误
这是我的代码:
SqlConnection Connect = new SqlConnection(Connection);
SqlCommand ProCommand = new SqlCommand("persons", Connect);
ProCommand.Parameters.AddWithValue("@Person", personName);
ProCommand.CommandType = CommandType.StoredProcedure;
Connect.Open();
ProCommand.ExecuteNonQuery();
SQL:
CREATE PROCEDURE Persons(@PersonType NVARCHAR (256))
AS
BEGIN
SET NOCOUNT ON;
BEGIN TRY
SET @info = 'SELECT BulkColumn FROM OPENROWSET (BULK''' +@PersonType+ ''',
SINGLE_CLOB) as j';
CREATE TABLE #tempTable (tempdata varchar (max));
INSERT INTO #tempTable
EXEC (@info);
DECLARE @Temp VARCHAR(max);
SELECT @Temp= tempdata FROM #tempTable;
BEGIN TRANSACTION
EXECUTE per.Group
COMMIT
END TRY
BEGIN CATCH
INSERT INTO main.[errorLog] ([Number],[Message], [Procedure],
[LineNumber], [Severity], [State])
VALUES (ERROR_NUMBER(), ERROR_MESSAGE(), ERROR_PROCEDURE(),
ERROR_LINE(), ERROR_SEVERITY(), ERROR_STATE());
DECLARE @ErrorMessage NVARCHAR(45);
SET @ErrorMessage = 'This error occured becuase ' +
CAST(SCOPE_IDENTITY() AS NVARCHAR(32));
THROW 50001, @ErrorMessage, 16;
END CATCH;
END;
GO