给出以下数组作为示例...
arr(0)(0) = 3
arr(0)(1) = name
arr(0)(2) = address
arr(1)(0) = 7
arr(1)(1) = name
arr(1)(2) = address
arr(2)(0) = 14
arr(2)(1) = name
arr(2)(2) = address
Run Code Online (Sandbox Code Playgroud)
我需要从数组中删除中间元素(id = 7).我知道我需要遍历数组并将每个不被删除的记录移动到一个新数组中.我试过这个......
Dim newArr,i
Redim newArr(Ubound(arr))
For i = 0 to Ubound(arr)
If (CStr(arr(i)(0)) <> 7 ) Then
newArr(i) = arr(i)
End if
Next
Run Code Online (Sandbox Code Playgroud)
调试时我可以看到if语句有效,所以我知道只复制了2个元素,但是newArr在结束时是空的.我错过了什么 我是一个PHP编码器,它是经典asp的新手,而且我常常使用数组函数来使这种东西变得不必要.任何帮助赞赏.谢谢.
我正在尝试在页面上放置一些内联服务器标签,以便使用Visual Studio 2012获取图像的正确路径.
我是这样做的:
<style type="text/css">
.someclass
{
background-image: url(<%=Url.Content("~/Content/Images/messageIcon.gif")%>);
}
</style>
Run Code Online (Sandbox Code Playgroud)
问题是,一旦写完,整个样式部分就会失去VS2012编辑器的颜色格式.tyhere是不同的方式(或VS2012中的一个选项),这样我就不会失去颜色和缩进?
我正在尝试在 Classic Asp 中使用 addheader -method 设置 cookie,这是向 cookie 添加 HttpOnly 和 Secure -flags 的唯一方法。所有这些都适用于以下代码 - 但有一个例外,它是到期日期/时间。
<%
Response.AddHeader "Set-Cookie", "testCookie=2000; path=/;HttpOnly;Secure;expires=" & dateAdd("d", 365, Now()) & ";samesite=Strict;HostOnly"
%>
Run Code Online (Sandbox Code Playgroud)
不过,这似乎是与浏览器相关的问题。在 Firefox 中,我可以在开发人员工具的“存储”选项卡中看到设置了过期时间。但在 Chrome 中,它始终保持默认状态,即会话结束时过期。Edge 也存在同样的问题。
有人对这个问题有经验吗?
如何在utf-8中保存文件?
Dim FSO, File
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set File = FSO.OpenTextFile(Path,2,true,-1)
File.Write(xml1)
File.Close
Set File = Nothing
Set FSO = Nothing
Run Code Online (Sandbox Code Playgroud) 按下取消按钮后,如何让我的VBScript取消进程?当按"确定"时,我希望VBScript打开一个新的InputBox.我已经得到了这个有点工作,但我也想给一个功能"取消"按钮.一个函数,可以阻止整个VBScript打开任何其他MsgBox或InputBox.
我尝试过这样的事情:
Set shell = createobject("wscript.shell")
strtext = InputBox("text")
vbCancel
If vbCancel then
WScript.Quit
End if
Run Code Online (Sandbox Code Playgroud) 我想将数据插入到我的tbl_Transaction_Master表中.这是我的数据库表tbl_Transaction_Master

我对数据库插入命令的查询是
SqlCommand cmd2 = new SqlCommand("insert into tbl_Transaction_Master(Supplier_ID,Order_Price,Unique_ID,Supplier_Name,He_Is_a,Transaction_Date) values ('" + WebUserID + "','" + Session["Order_Price"] + "','" + Session["WebUserid"] + "','"+User+"','WebCustomer',getdate()); SELECT SCOPE_IDENTITY()", conn);
int temp = cmd2.ExecuteNonQuery();
Session["order_ID"] = temp;
Run Code Online (Sandbox Code Playgroud)
我收到上面提到的错误.
我试图阻止除内部管理员IP地址以外的所有IP地址的特定url页(http://www.testdomain.com/login)。我没有阻止模式登录的问题,但是我想在本地进行测试,以确保将内部管理IP排除在/ login url的阻止规则之外。看看我到目前为止有什么...
<rewrite>
<rules>
<rule name="RequestBlockingRule1" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*login*" negate="false" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
<add input="{HTTP_X_Forwarded_For}" pattern="92.102.130.65" />
</conditions>
<action type="None" />
</rule>
<rule name="RequestBlockingRule2" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{URL}" pattern="*login*" />
</conditions>
<action type="CustomResponse" statusCode="404" statusReason="File or directory not found." statusDescription="The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable." />
</rule>
Run Code Online (Sandbox Code Playgroud)
我还想要重复相同的规则,但要查询http://www.testdomain.com/home.aspx的查询字符串?ctl = login
<rule name="RequestBlockingRule3" enabled="true" …Run Code Online (Sandbox Code Playgroud) 我需要能够遍历列名并将coloumn名称及其值放入变量中.我的代码看起来像这样.
SQL = "select column1, column2 from table1"
set rs = conn.execute(SQL)
For each fld in rs.fields
fld.name = rs(fld.name)
Next
rs.close
Run Code Online (Sandbox Code Playgroud)
但这不起作用.如何循环列名并将其设置为变量而无需指定每个列名?
谢谢
我正在尝试使用以下代码执行 .bat 以在我的本地主机(服务器端)上启动 notepad.exe:
索引.asp
<%
set wshell = CreateObject("WScript.Shell")
return = wshell.run("c:\file.bat", 4, false)
response.write(return)
set wshell = nothing
%>
Run Code Online (Sandbox Code Playgroud)
文件.bat
notepad.exe
Run Code Online (Sandbox Code Playgroud)
当我打开 ASP 页面时,没有任何反应。由于变量“return”,返回值 0。所以我尝试将false值设置为true,然后服务器冻结并且没有返回任何内容;我认为这是因为没有从 .bat 文件返回值。我还尝试直接运行 notepad.exe ( C:\Windows\notepad.exe ) 而不是使用 .bat 文件,但仍然没有任何反应。我也尝试使用 ASPExec.dll 但也无济于事。
有谁知道我做错了什么?
更多信息:
我的本地 Web 服务器是 Windows 7 附带的 IIS7。我在 localhost 上这样做只是为了测试目的。我必须在 Classic ASP 中完成此操作,因为最终我必须将网站导入 WinCE7 设备。我知道 WshShell 不适用于 WinCE,但现在我只是想看看它是否有效。最终,我将需要能够运行 .exe,通过网站在设备上安装更新。
我试图检查是否存在远程JPEG文件.如果是,则显示另一个显示另一个.ASP中是否有任何方法可以检查非本地文件?
我在asp中创建了一个类,想知道是否可以创建一个名为"END"的函数或子函数.即使作为子或函数,这是否可行.我想为我的类实例或像MyClass.End这样的类模块调用它的原因是然后调用response.end?
或者是否可以覆盖response.end函数以在结束前首先检查某些内容?
class Myclass
sub write(dim str)
response.write(str)
end write
' Is this "END" possible?
sub end
response.end
end sub
End class
Run Code Online (Sandbox Code Playgroud) 我使用以下代码尝试从我的代码文件中查找包含在另一个目录中的文件.
Set fi=fs.OpenTextFile(Server.MapPath("~/counter/counter.txt"), 1)
Run Code Online (Sandbox Code Playgroud)
我也试过了.
Set fi=fs.OpenTextFile(Server.MapPath("./root/folder1/counter/counter.txt"), 1)
Run Code Online (Sandbox Code Playgroud)
在任何一种情况下,这应该让我回到counter.txt文件.从我的理解〜/向上移动1个目录和./移动到根目录.
但是两次都收到错误,说明使用了无效字符.删除这些时,我得到一个不同的错误,说找不到路径(我希望这是因为它不是一个有效的路径而没有移动1个目录).
在VBscript中执行以下操作的有效字符是什么:向上移动一个目录?移动到根目录?
谢谢您的帮助