try
{
OpenConnection();
RowsAffected = cmd.ExecuteNonQuery();
CloseConnection(true); //should I use this function call here
//as well, when I am using it in finally
//block. For closing database connection.
}
catch (SqlException ex)
{ throw ex; }
finally
{ CloseConnection(true); }
Run Code Online (Sandbox Code Playgroud)
或者我应该这样写
try
{
OpenConnection();
RowsAffected = cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{ throw ex; }
finally
{ CloseConnection(true); }
Run Code Online (Sandbox Code Playgroud) 我正在写一个名为Food的课程.我考虑了一个字段"int cookingTime"来查看这个类的每个实例已存在多长时间.我以为我应该使用Timer类.我写了下面的一段代码,但它没有用.我不确定我的方法是否正确.我非常感谢任何帮助.
Class Food
{
private System.Timers.Timer timerClock = new System.Timers.Timer();
static int cookingTime = 0;
public Food()
{
this.timerClock.Elapsed += new System.Timers.ElapsedEventHandler(process);
this.timerClock.Interval = 1000;
this.timerClock.Enabled = true;
}
static void process(Object myObject, EventArgs myEventArgs)
{
cookingTime += 1;
}
}
Run Code Online (Sandbox Code Playgroud) 我必须在c#中的文本更改事件中自动插入9位数的连字符,而不是javascript.
所以如果我的号码是123456789那么它会自动变成12345-6789.
我想使用regex.match.
我的尝试:
正则表达式"^\d {5}( - \d {4})?$"是结果应该如何.
所以,
Regex regTest = new Regex("^\\d{5}(-\\d{4})?$");
Match match = regTest.Match(s);
if (match.Success)
{
var numString = match.Value;
}
Run Code Online (Sandbox Code Playgroud)
但上述情况并未取得成功.
感谢帮助.
我将2个序列化对象存储在2个文本文件中然后我读取它们并将其存储在2个不同的字符串中,并尝试比较这2个字符串,由于回车和新行差异,比较失败了一次以上其中一个字符串,我怎么能比较忽略空格或回车,我知道我可以压缩2个字符串并比较它们,但有没有像.net库那样做,像Icomparer一样,我不确定这是不是对我也有用.
Jp.提前谢谢你
我有一个问题,让我的下拉显示在IE6中.它似乎在IE7和8中工作正常.任何帮助将不胜感激
这是一个预览链接:http: //arrowheadproducts.net.c1.previewmysite.com/2010Nov/index.aspx
这是HTML:
<div id="nav">
<div id='leftheader_top'><img src='images/logo2.jpg' /></div>
<div id="top_nav01"><a id="nav01" href="index.aspx"></a></div>
<div id="top_nav02">
<div class='list'>
<ul>
<li><a id="nav02" href="products.aspx"></a>
<ul>
<li><a border='0' id="drop_01" href="metalsystemsandproducts.aspx"></a></li>
<li><a border='0' id="drop_02" href="compositesystemsandcomponents.aspx"> </a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="top_nav03">
<div class='list'>
<ul>
<li><a id="nav03" href="services.aspx"></a>
<ul>
<li><a border='0' id="drop_02_01" href="engineering.aspx"></a></li>
<li><a border='0' id="drop_02_02" href="testing.aspx"></a></li>
<li><a border='0' id="drop_02_03" href="manufacturing.aspx"></a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="top_nav04">
<div class='list'>
<ul>
<li><a id="nav04" href="support.aspx"></a>
<ul>
<li><a border='0' id="drop_03_01" href="warranty.aspx"></a></li>
<li><a border='0' …Run Code Online (Sandbox Code Playgroud) 我有像这样的.xml:
<Type>
<Connections>
<Conn ServerName="serv1" DataBase="Persons" User="admin" Pass="123"/>
<Conn ServerName="serv2" DataBase="Type123" User="admin" Pass="123"/>
</Connections>
<UDLFiles>
<UDL Path="C:\Test.UDL>
</UDLFiles>
</Type>
Run Code Online (Sandbox Code Playgroud)
我想保存所有string[] ServerNames;DataBases中的所有ServerNames string[] DataBases;等等......如何获取此XML的所有这些属性?我尝试用:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(path);
XmlNodeList conn = xmlDoc.GetElementsByTagName("Conn");
foreach (XmlNode item in conn)
{
//item.Attributes;
}
Run Code Online (Sandbox Code Playgroud)
但我无法使用此代码获取Atributes ...任何想法?
要在运行时创建Button及其click事件,我使用:
Button b = new Button();
b.Name = "btn1";
b.Click += btn1_Click;
Run Code Online (Sandbox Code Playgroud)
但是现在我在运行时创建了一系列按钮; 如何设置每个按钮的事件 - 我无法插值,因为它不是一个字符串.
Button[] b = new Button(Count);
for (int i=0; i < Count; i++)
{
b[i] = new Button();
b[i].Name = "btn" + i;
b[i].Click += ??????
}
Run Code Online (Sandbox Code Playgroud)
我该怎么办"?????"
我是MVC3的新手所以请耐心等待.我创建了默认的ASP.NET MVC3应用程序.那里有一个简单的注册页面.
所以调用过程是这样的:
我想知道,为什么需要Model?我的意思是,应该做什么模型?任何答案将不胜感激!谢谢.
我收到以下错误.我无法弄清楚缺少什么,因为我似乎已经将所有括号都匹配了.
错误:意外')':"{if(grepl(propertiesData [x,'city'],population [z,'NAME'],ignore.case = TRUE)&(propertiesData [x,'stateLong'] ==人口[Z, 'Statename的')"
这是循环的代码:
for (z in c(1:nrow(population)))
{
if (grepl(propertiesData[x,'city'],population[z,'NAME'],ignore.case=TRUE) & (propertiesData[x,'stateLong']==population[z,'STATENAME'))
{
propertiesData[x,'population']=population[z,'POP_2009']
break
}
}
Run Code Online (Sandbox Code Playgroud) 命令行参数要么馈入批处理文件并通过批处理文件读取,要么在批处理文件中进行硬编码
Set Target_computer = %1
REM Get Source URL
Set SOURCE_URL = %2
REM Set Source Directory
SET SOURCE_DIR = \reference_data_update
Run Code Online (Sandbox Code Playgroud)
并在执行bat文件时显示。但是,当其中两个串联时
xcopy %SOURCE_URL%%SOURCE_DIR% d:\dqxi\11_7\reference_data /Y/H/S/R
Run Code Online (Sandbox Code Playgroud)
他们没有被阅读。该命令回显为
xcopy d:\dqxi\11_7\reference_data /Y/H/S/R
Run Code Online (Sandbox Code Playgroud)
如何使这些变量在批处理文件中工作以执行需要bat文件执行的工作(从源服务器的reference_data_update目录到目标服务器的reference_data目录的xcopy)?