我看到了类似的问题,但我的情况略有不同:
我在IIS 7.5服务器(R2008 V2)上使用#include文件得到间歇性结果.我的包含仅在与当前.asp页面位于同一文件夹中或当前页面的子文件夹中时才起作用.这很不方便,因为我想将它们全部保存在主页面之外的/ lib子文件夹中.
我的配置:我有一个名为DCN的文件夹,位于wwwroot文件夹的正下方.DCN文件夹中的/ lib文件夹中有多个文件,因此绝对路径为c:\ inetpub\wwwroot\dcn\lib\my_include_file.asp.如果我在DCN文件夹中打开一个ASP页面,我可以从/ lib子文件夹中提取包含文件.但是,如果我从DCN/trouble文件夹打开一个ASP页面(例如"DCN\Trouble\Search.asp"),并且search.asp页面有一行说明:
<!--#include file="../lib/my_include_file.asp"-->
Run Code Online (Sandbox Code Playgroud)
包含失败,我得到500错误.
我也尝试过:
<!--#include file="/lib/my_include_file.asp"-->
Run Code Online (Sandbox Code Playgroud)
结果相同.与:相同:
<!--#include file="/DCN/lib/my_include_file.asp"-->
Run Code Online (Sandbox Code Playgroud)
我将斜杠更改为反斜杠,结果相同.我甚至尝试过:
<!--#include file="c:\inetpub\wwwroot\dcn\lib\my_include_file.asp"-->
Run Code Online (Sandbox Code Playgroud)
(出于纯粹的解散),但我仍然得到相同的结果.
如果我在dcn\trouble文件夹中创建一个子文件夹,我可以包含它的文件,但很明显,这并不理想.
任何建议将不胜感激.我不禁想到这是微不足道的.提前致谢!
这很奇怪.我的c#应用程序中有一个非常简单的SQL查询,用于计算SQL Server表中的记录.代码段如下:
// Returns the number of ports defined for a given slot.
int returnval = 0;
connection.Open();
SqlCommand command = new SqlCommand("SELECT COUNT(Slotted_Port_UID) FROM tblSlottedCardPorts WHERE Slot_ID = @SlotID ", connection);
command.Parameters.AddWithValue("@SlotID", EquipmentSlotID);
SqlDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
if (!reader.IsDBNull(0))
{
returnval = reader.GetInt32(0);
}
}
reader.Close();
connection.Close();
return returnval;
Run Code Online (Sandbox Code Playgroud)
当我将SQL语句直接复制并粘贴到SQL Server mgmt studio中时,查询将按预期返回,返回0或正整数,具体取决于行数.但是,尽管代码传递了.HawRows条件,但它在reader.IsDBNull(0)条件上失败.tblSlottedCardPorts存在,Slotted_Port_UID列是唯一的整数.有什么建议吗?我无法理解为什么COUNT会返回Null值,因为不涉及连接或其他因素.
感谢您的任何建议!
米切尔