我在sql server上调用存储过程,如下所示:
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);
}
Run Code Online (Sandbox Code Playgroud)
它连接并执行命令,但它没有返回任何数据返回和参数是正确的(当我在sql中使用相同的参数调用该过程时,它返回给我一个结果)
这是proc:
ALTER PROCEDURE [dbo].[spSearchKeywords]
(
@VALUE NVARCHAR(50) = NULL,
@ACCOUNTGROUPID NVARCHAR(50) = NULL,
@ShortCodeId NVARCHAR(50) = NULL,
@VALUETYPE NVARCHAR(50) = NULL,
@ASSEMBLY NVARCHAR(100) …Run Code Online (Sandbox Code Playgroud)