出于某种原因,我的存储过程在C#中没有任何代码隐藏错误的情况下执行,但它并没有删除存储过程所写的任何内容.我有所有正确的参数和一切.我使用C#代码中的所有相同参数从SQL Server运行查询,它运行正常.当我从SQL Server运行时,我不明白为什么它工作,但是当我从Visual Studio中的C#代码运行它时它不起作用.
这是我的C#代码,它将数据传递给存储过程.
string reportType = "PostClaim";
string GRNBRs = "925','926','927";
string PUNBRs = "100','100','100";
string beginningDates = "20120401";
string endDates= "20120430";
try
{
conn = new SqlConnection(ConnectionInfo);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("RemoveReport", conn);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.AddWithValue("@ReportType", reportType);
da.SelectCommand.Parameters.AddWithValue("@GRNBR", GRNBRs);
da.SelectCommand.Parameters.AddWithValue("@PUNBR", PUNBRs);
da.SelectCommand.Parameters.AddWithValue("@DATE1", beginningDates);
da.SelectCommand.Parameters.AddWithValue("@DATE2", endDates);
da.SelectCommand.CommandTimeout = 360;
}
catch (SqlException ex)
{
//something went wrong
throw ex;
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
Run Code Online (Sandbox Code Playgroud)
这是我的存储过程.它正在使用动态SQL文本执行.
ALTER PROCEDURE [dbo].[RemoveReport] (
@ReportType NVARCHAR(20),
@GRNBR …Run Code Online (Sandbox Code Playgroud)