奇怪的是这个.如果我构建我的c#VS2005项目,则构建失败,它应该这样做.但是,如果我点击F5应用程序运行.我认为它使用的是最后一个良好的版本,但我不能为生命而告诉我在哪里关闭它.我也记不起来了!!
任何帮助赞赏
杰森
我想做这个
SELECT *
FROM sales_order_header
WHERE order_reference LIKE @order_reference + '%'
AND ((@booked_in IS NULL) OR ( booked_in = @booked_in))
AND ((@depot_assigned IS NULL) OR ( IF @depot_assigned = 'Y' depot_code <> ' ' ELSE depot_code = ' ') )
Run Code Online (Sandbox Code Playgroud)
我相信你们都可以猜到OR(IF @dede_assigned等)位失败了.
我该怎么做这样的事情,或者我必须根据@depot_assigned参数的值将它作为两个单独的select语句来完成.
如果我有这样的事情:
using( SqlCommand sqlCmd = CreateSqlCommand( "load_collection_get", false ) )
{
// Code
}
Run Code Online (Sandbox Code Playgroud)
CreateSqlCommand看起来像:
public static SqlCommand CreateSqlCommand( string storedProc, bool transaction )
{
SqlCommand sqlCmd = new SqlCommand( storedProc, sqlHelper.GetConnection() );
sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
if( transaction )
sqlCmd.Transaction = sqlHelper.GetTransaction();
return ( sqlCmd );
}
Run Code Online (Sandbox Code Playgroud)
SqlHelper.GetConnection()返回一个打开的SqlCommand对象
在使用结束时(SqlCommand ...)会为我关闭连接吗?或者我仍然需要在使用结束前调用SqlConnection.Close?