在代码中,我们说:
using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ToString()))
{
cn.Open();
// Set all previous settings to inactive
using (SqlCommand cmd = new SqlCommand("UPDATE tblSiteSettings SET isActive = 0", cn))
{
cmd.ExecuteNonQuery();
}
cn.Close();
}
Run Code Online (Sandbox Code Playgroud)
这cn.close在技术上是不必要的,因为垃圾收集将为我们处理连接.
但是,我总是喜欢关闭它,不依赖于垃圾收集.这不好吗?浪费时间?或者考虑不依赖自动化的良好做法?
提前感谢您的想法和意见.我将此标记为社区维基,因为它可能是主观的.
我已经看了六个CSS优化器.我正在寻找的是一个将转向:
background-image: url(../images/background.png);
background-repeat: repeat-x;
background-color: #c0c0c0;
Run Code Online (Sandbox Code Playgroud)
进入单个背景属性:
background: #c0c0c0 url(../images/background.png) repeat-x;
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?我必须手工完成吗?
我有一个输入框,人们输入一个字体,它保存了他们键入的JPEG格式.一切正常.但是,当他们键入一个字体名称,如' times new roman'它必须正确地大写' Times New Roman'或它不会工作!
我可以以某种方式迭代所有可用的字体并将其作为下拉列表呈现给它们,这样就没有拼写问题,它们肯定只会在系统上使用字体吗?
我从用户那里得到了相当频繁的错误报告,典型的一个是:
Error Message: Row not found or changed.
Stack Trace:
at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at Controls_Article_ArticleViewer.LoadArticle()
at ViewTutorial.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Run Code Online (Sandbox Code Playgroud)
(如果需要,我可以提供更多细节).该函数中唯一直接的LINQ代码LoadArticle()是:
using (MainContext db = new MainContext())
{
var q = (
from A in db.tblArticles
where A.ID == this.ArticleID && A.IsDeleted == false
select A
).SingleOrDefault();
if (q == null)
{
Server.Transfer("~/404.aspx");
Context.Response.End();
}
else
{
// Cache …Run Code Online (Sandbox Code Playgroud) /// <summary>
/// Returns list of popular searches
/// </summary>
public static string[] getPopularSearches(int SectionID, int MaxToFetch)
{
using (MainContext db = new MainContext())
{
return (from c in db.tblSearches where c.SectionID == SectionID && c.Featured select new[] { c.Term });
}
}
Run Code Online (Sandbox Code Playgroud)
我看了其他问题,但它们似乎略有不同,我得到了错误:
Cannot implicitly convert type 'System.Linq.IQueryable<string[]>' to 'string[]'
Run Code Online (Sandbox Code Playgroud)
我知道这可能很简单,有人可以指出这里有什么问题吗?
我在IIS 7.5上运行经典ASP和ASP.net 4.0.
在我的经典ASP代码是这段代码:
' Process @ alerts
Dim objHttp
set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
objHttp.open "POST", strSiteRoot & "handlers/forumalerts.ashx?", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send "topicID=" & lngTopicID & "&threadID=" & lngLastPostID
set objHttp = nothing
Run Code Online (Sandbox Code Playgroud)
这是向ASP.net ASHX处理程序发送请求.运行时,它会在最终发送错误消息之前挂起很长时间:
msxml3.dll错误'800c0008'
指定资源的下载失败.
/forum/new_post.asp,第1036行
我已经检查了它发布到的URL,它存在且正在运行.发送的数据也是正确的.
在我全新安装Windows 7之前,它运行良好.由于重新安装它,并再次设置IIS这段代码失败,让我相信它是一个权限/身份错误.
有谁能告诉我是什么原因造成的?我有3个应用程序池:
ASP.net v4.0 (Integrated) (ApplicationPoolIdentity)
ASP.net v4.0 Classic (Classic) (ApplicationPoolIdentity)
DefaultAppPool (Integrated) (NetworkService)
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
编辑:我在日志中发现了这个错误:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 02/11/2011 14:55:42
Event time (UTC): 02/11/2011 14:55:42
Event ID: 4e550d910b934d2781707701f833e18e …Run Code Online (Sandbox Code Playgroud) 我正在使用这段简短的代码:
var d = itemID + "," + quantity;
var CookieData = $.cookie("storebasket");
if(CookieData == null || CookieData == "") {
$.cookie("storebasket", d, { path: '/', expires: 60 });
} else {
$.cookie("storebasket", CookieData + "|" + d, { path: '/', expires: 60 });
}
Run Code Online (Sandbox Code Playgroud)
但是,值ALWAYS将变为HTML编码.例如:
5%2C1
Run Code Online (Sandbox Code Playgroud)
5,1
Run Code Online (Sandbox Code Playgroud)
我尝试过unescape但没有运气:
$.cookie("storebasket", unescape(d), { path: '/', expires: 60 });
Run Code Online (Sandbox Code Playgroud)
还有什么想法吗?
给出饼图的数据:
data = new google.visualization.arrayToDataTable([
['Sales', 'Revenue Distribution'],
['Author', 5],
['Company', 2],
['Tax', 0.4],
['Payment Processors', 0.9]
]);
drawChart();
Run Code Online (Sandbox Code Playgroud)
如何将其显示为美元金额?无论是在工具提示中还是在实际图形本身上(两者都更可取!)
例如,理想情况下这可以工作:
data = new google.visualization.arrayToDataTable([
['Sales', 'Revenue Distribution'],
['Author', '$5'],
['Company', '$2'],
['Tax', '$0.4'],
['Payment Processors', '$0.9']
]);
drawChart();
Run Code Online (Sandbox Code Playgroud) 鉴于这些整数:
public uint ServerSequenceNumber;
public uint Reserved1;
public uint Reserved2;
public byte Reserved3;
public byte TotalPlayers;
Run Code Online (Sandbox Code Playgroud)
byte[]从它们创建数组的最佳方法是什么?如果它们的所有值都是1结果数组将是:
00000000000000000000000000000001 00000000000000000000000000000001 00000000000000000000000000000001 00000001 00000001
Run Code Online (Sandbox Code Playgroud) 我有 iframe:
<iframe id="GameFrame"
sandbox="allow-scripts allow-pointer-lock"
src="https://127.0.0.1:112/games/1047/play">
</iframe>
Run Code Online (Sandbox Code Playgroud)
我的父页面位于:
https://127.0.0.1/arcade/not-hidden/space-blaster-1047
Run Code Online (Sandbox Code Playgroud)
我正在尝试向 iFrame 发布消息:
var gameIframe = $("#GameFrame");
gameIframe.get(0).contentWindow.postMessage("screenshot", "");
Run Code Online (Sandbox Code Playgroud)
但这会引发错误:
未捕获的语法错误:无法在“窗口”上执行“postMessage”:在调用“postMessage”时目标源“无效”。
其他尝试:
postMessage("screenshot", "https://127.0.0.1");
Run Code Online (Sandbox Code Playgroud)
无法在“DOMWindow”上执行“postMessage”:提供的目标源(“ https://127.0.0.1 ”)与收件人窗口的源(“null”)不匹配。
我怎样才能得到这个发布到 iFrame 的消息?
c# ×5
asp.net ×3
linq ×2
arrays ×1
asp-classic ×1
byte ×1
bytearray ×1
conflict ×1
cookies ×1
css ×1
escaping ×1
font-face ×1
font-family ×1
fonts ×1
formatting ×1
html ×1
html-encode ×1
iframe ×1
iis-7 ×1
javascript ×1
jquery ×1
loops ×1
optimization ×1
postmessage ×1
sandbox ×1
string ×1