程序设计

专业和发烧友程序员的问答

18
将空值分配给SqlParameter
下面的代码给出了一个错误-“没有从DBnull到int的隐式转换”。 SqlParameter[] parameters = new SqlParameter[1]; SqlParameter planIndexParameter = new SqlParameter("@AgeIndex", SqlDbType.Int); planIndexParameter.Value = (AgeItem.AgeIndex== null) ? DBNull.Value : AgeItem.AgeIndex; parameters[0] = planIndexParameter;
188 c#  dbnull  sqlparameter 

18
如何在Swift中连接字符串?
如何在Swift中连接字符串? 在Objective-C我们喜欢 NSString *string = @"Swift"; NSString *resultStr = [string stringByAppendingString:@" is a new Programming Language"]; 要么 NSString *resultStr=[NSString stringWithFormat:@"%@ is a new Programming Language",string]; 但是我想用Swift语言做到这一点。

8
如何在SSMS 2008的“编辑前200行”中更改SQL
在SQL Server 2008 Management Studio中,当我右键单击数据库表并选择“ 选择前100行 ”时,例如,我可以轻松地向SQL添加“ ORDER BY”语句。那很好。 但是,当我确实选择“ Edit Top 200 Rows ”时,我无法更改 SQL(这使得查找和编辑刚刚添加到其中的10,000条记录变得困难。 我非常确定我能够在SQL Server 2000中做到这一点。 SMSS 2008中有什么方法可以更改在编辑记录时显示记录的方式?

30
UIButton:使匹配区域大于默认匹配区域
我有一个关于UIButton及其命中区域的问题。我在界面构建器中使用“信息暗”按钮,但是发现命中区域不足以容纳某些人的手指。 有没有一种方法可以通过编程方式或在Interface Builder中增加按钮的点击区域,而无需更改InfoButton图形的大小?

3
Xcode 4.4发行说明中提到的“ Objective-C Literals”的详细信息是什么?
我正在查看Xcode 4.4的发行说明,并注意到了这一点: LLVM 4.0编译器 Xcode现在包括Apple LLVM编译器版本4.0,其中包括以下新的 Objective -C语言功能:[...] -Objective-C文字:为NSArray,NSDictionary和NSNumber创建文字,与NSString的文字相同 我对此功能很感兴趣。它并不完全清楚,我只是如何文字NSString工作和一个如何使用它们NSArray,NSDictionary和NSNumber。 有什么细节




3
ModelState.AddModelError-如何添加非属性错误?
我正在检查数据库,Create(FooViewModel fvm){...}以查看fvm.prop1和fvm.prop2在该组合中是否已经存在;如果是这样,我想向模型状态添加错误,然后返回整个视图。我试过了: public ActionResult Create(FooViewModel fvm){ if (ThatComboAlreadyExists(fvm)) { ModelState.AddModelError("Model", "There is already one like that"); return View(fvm); } } ...但是我没有显示中的错误Html.ValidationSummary,我认为这是错误的出现位置。我怀疑“模型”不是正确的键,但是我找不到Google那样的东西。


25
获取java.lang.ClassNotFoundException:org.apache.commons.logging.LogFactory异常
我正在执行spring的简单Dependency Injection程序并获取此异常。我已经包含了common-logging1.1.1.jar和spring.jar文件。你能帮忙吗? Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:119) at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:55) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56) at com.client.StoryReader.main(StoryReader.java:15) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 6 more

9
我需要同时关闭FileReader和BufferedReader吗?
我正在使用包裹在FileReader周围的BufferedReader读取本地文件: BufferedReader reader = new BufferedReader(new FileReader(fileName)); // read the file // (error handling snipped) reader.close(); 我需要close()的FileReader为好,或将包装处理这个问题?我看过代码,人们在其中执行以下操作: FileReader fReader = new FileReader(fileName); BufferedReader bReader = new BufferedReader(fReader); // read the file // (error handling snipped) bReader.close(); fReader.close(); 从Servlet调用此方法,并且我想确保我没有打开任何句柄。

8
如何列出所有DNS记录?
有什么办法可以列出域的所有DNS记录? 我知道诸如dig和nslookup之类的东西,但它们只是走得太远了。例如,如果我有一个子域A记录为 test A somedomain.co.uk 除非我特别要求,例如 dig any test.somedomain.co.uk 我看不到 有什么方法(除了通过转到DNS管理器查看记录之外)以准确地查看所有DNS记录是什么?
188 dns 


25
Android,ListView IllegalStateException:“适配器的内容已更改,但ListView没有收到通知”
我想做的是:运行后台线程,该线程计算ListView的内容并部分更新ListView,同时计算结果。 我必须避免的是:我无法弄乱后台线程中的ListAdapter内容,因此我继承了AsyncTask并从onProgressUpdate发布结果(向适配器添加条目)。我的适配器使用结果对象的ArrayList,对这些arraylist的所有操作均已同步。 其他人的研究:有非常有价值的数据在这里。对于大约500个用户的组,我几乎每天都遭受崩溃,当我list.setVisibility(GONE)/trackList.setVisibility(VISIBLE)在onProgressUpdate中添加块时,崩溃降低了10倍,但没有消失。(有人在回答中建议) 我有时得到的结果:请注意,这种情况很少发生(3.5k用户之一一周一次)。但我想完全摆脱这个错误。这是部分堆栈跟踪: `java.lang.IllegalStateException:` The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131296334, class android.widget.ListView) with Adapter(class com.transportoid.Tracks.TrackListAdapter)] at android.widget.ListView.layoutChildren(ListView.java:1432) at android.widget.AbsListView.onTouchEvent(AbsListView.java:2062) …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.