我遵循的语法
INSERT INTO Table1
VALUES (value1, value2, value3…)
Run Code Online (Sandbox Code Playgroud)
到目前为止这个工作得很好.但现在我有一些包含普通英文文本的值,比如"我要回家了".'字符破坏了C#中的SQL命令.我写了以下内容:
command.CommandText = "INSERT INTO Bio VALUES ('" + name + "','"I'm going home" + "');
Run Code Online (Sandbox Code Playgroud)
评估为
INSERT INTO Bio VALUES ('Peter','I'm going home')
Run Code Online (Sandbox Code Playgroud)
这显然是行不通的.如何确保特殊字符不会破坏SQL语句?
我正在维护一个包含客户信息的程序.它由许多表单组成,每个表单都显示数据库中的一些相关信息.执行以下操作后,此错误是单一形式
这是失败的代码:
private void FireFileCountChanged() {
if (FileCountChanged != null)
BeginInvoke(new DeferEvent(FireFileCountChangedDeferred), 2); // FAILS
Run Code Online (Sandbox Code Playgroud)
"System.Windows.Forms.dll中发生了'System.InvalidOperationException'类型的未处理异常
附加信息:在创建窗口句柄之前,无法在控件上调用Invoke或BeginInvoke."
我尝试添加以下内容:
private void FireFileCountChanged() {
if (FileCountChanged != null && this.Handle != null) // CHANGED AND FAILS.
BeginInvoke(new DeferEvent(FireFileCountChangedDeferred), 2);
}
Run Code Online (Sandbox Code Playgroud)
但是this.handle给出了:
'this.Handle'抛出了'System.ObjectDisposedException'类型的异常,并且"无法访问已处置的对象.\ r \n对象名称:'AttachmentsControl'."
然后我添加了10秒的超时作为方法的第一行,但仍然没有创建句柄.当其中一个窗户关闭时,手柄是否已被处理掉?那可以做些什么呢?任何帮助表示赞赏.我有点卡住了.
private void FireFileCountChangedDeferred(int repostCount) {
if (FileCountChanged != null) {
if (repostCount > 0) {
//black magic is somehow involved in getting this event to fire *after* the filewatcher reports the change. …Run Code Online (Sandbox Code Playgroud) 我想读取远程桌面的端口号,但它不起作用.
MSDN声明它是在
HKEY_LOCAL_MACHINE \系统\ CurrentControlSet \控制\的TerminalServer\WinStations\RDP-TCP\PORTNUMBER
这是我在Windows 8上的注册表中存在的密钥.
private void Form1_Load(object sender, EventArgs e)
{
txtPort.Text = (string) Registry.GetValue(@"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp", "PortNumber", "");
}
Run Code Online (Sandbox Code Playgroud)
返回的字符串为null.
正确答案:
private void Form1_Load(object sender, EventArgs e)
{
txtPort.Text = Registry.GetValue(@"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\", "PortNumber", -1).ToString();
}
Run Code Online (Sandbox Code Playgroud) 我用来HtmlAgilityPack从一个网站获取业余爱好项目的数据.我想从销售鞋子的网站上获取鞋子产品编号.
但我的linq查询不返回字符串.相反,它返回类型:
System.Linq.Enumerable.WhereSelectEnumerableIterator<HtmlAgilityPack.HtmlNode,string>
Run Code Online (Sandbox Code Playgroud)
如何让查询只返回一个字符串?
foreach (var node in query)
{
Shoe shoe = new Shoe();
var num = from x in node.Descendants()
where x.Name == "img" && x.Attributes.Contains("class") && x.Attributes["class"].Value == "thumb lazy"
select x.Attributes["title"].Value.Substring(11);
shoe.articleNumber = Convert.ToInt32(num); //error
shoes.Add(shoe);
}
Run Code Online (Sandbox Code Playgroud)
错误:InvalidCastException未处理.
无法将类型为'WhereSelectEnumerableIterator`2 [HtmlAgilityPack.HtmlNode,System.String]'的对象强制转换为'System.IConvertible'.
我收到这片xml:
<hash>
<base>XPM</base>
<alt>BTC</alt>
<value type="decimal">0.00341</value>
</hash>
Run Code Online (Sandbox Code Playgroud)
如何获取base,alt和value标记的值?我还想知道type属性是十进制的.
我想看看函数Digest :: SHA2.hexdigest创建的哈希.我没有安装Ruby,所以我去了在线irb.打字
Digest::SHA2.hexdigest("hello")
Run Code Online (Sandbox Code Playgroud)
给
=> #<NameError: uninitialized constant Digest>
Run Code Online (Sandbox Code Playgroud)
是否可以在任何在线irb中添加所需的库?
我想为每个具有"章节"类的div标签添加个人ID.通过放入一个警告框,我检查它确实迭代了超过16个元素,这是预期的,因为这是具有类"章节"的div元素的数量.我尝试添加另一个类(通过addClass)并向元素添加id,如下所示.但它不起作用.我在这里错过了什么?
JavaScript的:
$(document).ready(function() {
$(".chapter").each(function(index) {
$(this).attr('id', 'chapter' + index + 1);
});
});
Run Code Online (Sandbox Code Playgroud)
HTML:
!DOCTYPE html>
<html>
<head>
<title>Programming examples for 70-480</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="70-480.js"></script>
</head>
<body>
<h1>Programming examples for 70-480</h1>
<h4>Training Guide Programming in HTML5 with JavaScript and CSS3</h4>
<ul>
<div class="chapter"><li>Chapter 1: Getting started with Visual Studio 2012 and Blend for Visual Studio 2012</li>
<ul>
<li>Lesson 1: Visual Studio 2012</li>
<li>Lesson 2: Blend for Visual Studio 2012</li>
</ul>
</div>
<div class="chapter"><li>Chapter 2: Getting started with …Run Code Online (Sandbox Code Playgroud) 我有一些来自System.AddIn的插件.但是在运行AddInStore.Rebuild时
string[] warnings = AddInStore.Rebuild(addInRoot);
Run Code Online (Sandbox Code Playgroud)
然后我收到一个警告字符串:
该文件不是有效的二进制文件:D:\ AK\AS\ConverterModule\output\AddIns\CompositeFileZip\7z.dll文件名:D:\ AK\AS\ConverterModule\output\AddIns\Composi ...
7z.dll不是插件程序集,而是CompositeFileZip插件使用的7z文件.我无法弄清楚重建功能到底在做什么.它是否尝试将7z.dll添加为插件?
我有一个由47个项目组成的解决方案.有一个安装程序项目,生成setup.exe文件和msi文件.运行setup.exe将直到今天安装Windows服务没有任何问题.现在我收到错误:
无法加载一个或多个请求的类型.检索LoaderExceptions属性以获取更多信息.
谷歌搜索后,似乎我已经做了一个不是最新的项目清理/重建.我怎么看它是什么?如何查看LoaderExceptions属性?
我在以下实现中有错误.它说OnlineWebStore_Process无法实现IWebStore接口,因为它们没有匹配的返回类型.但该方法返回Item,它实现了在IWebStore接口中用作返回类型的IItem接口.什么是这个问题的好方法?
public interface IItem
{
string id { get; set; }
string name { get; set; }
}
public interface IWebStore
{
List<IItem> GetOnlineItems();
}
public class Item : IItem
{
public Item(string _id)
{
id = _id;
}
public string id { get; set; }
public string name { get; set; }
}
public class OnlineWebStore_Process : IWebStore
{
public List<Item> GetOnlineItems()
{
List<Item> items = new List<Item>();
return items
}
}
Run Code Online (Sandbox Code Playgroud) c# ×8
begininvoke ×1
handle ×1
installer ×1
interface ×1
irb ×1
javascript ×1
jquery ×1
linq ×1
registry ×1
ruby ×1
sql ×1
system.addin ×1
xml ×1