J'appelle une procédure stockée sur le serveur sql comme ceci:appel à la procédure stockée ne retourne rien
SqlConnection conn = new SqlConnection();
SqlCommand cmd;
XmlDocument xmlDocument;
XmlReader xr;
XmlNode node;
SqlDataReader rdr = null;
try
{
xmlDocument = new XmlDocument();
conn.ConnectionString = "Data Source=test;Initial Catalog=teste;Integrated Security=SSPI;";
cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "[dbo].[spSearchKeywords]";
cmd.Parameters.Add(new SqlParameter("@VALUE", "XPT"));
conn.Open();
xr = cmd.ExecuteXmlReader();
conn.Close();
node = xmlDocument.ReadNode(xr);
}
la connexion et l'exécution de la commande, mais il ne retourne rien il y a des données pour revenir et les paramètres sont corrects (quand je l'appelle la procédure sql avec le même paramètre, il me renvoie un résultat)
ici est le proc:
ALTER PROCEDURE [dbo].[spSearchKeywords]
(
@VALUE NVARCHAR(50) = NULL,
@ACCOUNTGROUPID NVARCHAR(50) = NULL,
@ShortCodeId NVARCHAR(50) = NULL,
@VALUETYPE NVARCHAR(50) = NULL,
@ASSEMBLY NVARCHAR(100) = NULL,
@ASSEMBLYCONTAINSURI NCHAR (10) = NULL,
@ASSEMBLYTYPE NVARCHAR(50) = NULL
)
AS
BEGIN
SET NOCOUNT ON;
SELECT [Value]
,[AccountGroupId]
,[ShortCodeId]
,[ValueType]
,[assembly]
,[assemblyContainsUri]
,[assemblyType]
FROM [teste].[dbo].[keywords]
WHERE [Value] = ISNULL(@VALUE, [Value])
AND [AccountGroupId] = ISNULL(@ACCOUNTGROUPID, [AccountGroupId])
AND [ShortCodeId] = ISNULL(@SHORTCODEID, [ShortCodeId])
AND [ValueType] = ISNULL(@VALUETYPE, [ValueType])
AND [assembly] = ISNULL(@ASSEMBLY, [assembly])
AND [assemblyContainsUri] = ISNULL(@ASSEMBLYCONTAINSURI, [assemblyContainsUri])
AND [assemblyType] = ISNULL(@ASSEMBLYTYPE, [assemblyType])
FOR XML AUTO
END
Pourquoi utilisez-vous XML? – SLaks
Je suis d'accord avec SLaks. XML et SQL Server sont deux choses qui n'auraient jamais dû être «intégrées». – NotMe