J'ai une procédure stockée, qui fonctionne comme il faut dans le query Analyser.
Mais quand je l'utilise dans mon application, j'obtiens cette erreure, quand je fill mon DataSet
System.InvalidOperationException: String[0]: the Size property has an invalid size of 0
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 public static string Phase_GetName(int Id) { string sProc = "pTable_GetName"; SqlConnection dbconnection = new SqlConnection(_connectionString); DataSet ds = new DataSet(); SqlCommand command = new SqlCommand(sProc, dbconnection); SqlDataAdapter da = new SqlDataAdapter(command); command.CommandType = CommandType.StoredProcedure; SqlParameter parameterOutput = command.Parameters.Add("@Name", SqlDbType.VarChar); parameterOutput.Direction = ParameterDirection.Output; command.Parameters.Add("@Id", SqlDbType.Int).Value = Id; da.Fill(ds); //<---ERREUR ICI return parameterOutput.Value.ToString(); }Merci beaucoup de votre aideSET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
ALTER PROCEDURE pTable_GetName
(
@Name varchar(50) OUTPUT,
@Id int
)
AS
BEGIN
SELECT @Name = Table.Name FROM Table WHERE Table.ID=@Id
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Partager