我正在尝试将新记录插入到MS SQL数据库中,并且我得到了一个我以前从未见过的异常.当我调用时executeUpdate抛出以下异常:
com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update.
这是产生错误的Java代码:
// addComment method adds a new comment for a given requestId
public CommentBean addComment(CommentBean comment) {
PreparedStatement stmt = null;
INative nat = null;
Connection conn = null;
try {
nat = dbConn.retrieveNative();
conn = (Connection)nat.getNative("java.sql.Connection");
stmt = conn.prepareStatement(ADD_COMMENT);
stmt.setInt(1, comment.getRequestId());
stmt.setString(2, comment.getComment());
stmt.setString(3, new SimpleDateFormat("MM/dd/yyyy").format(comment.getDateCreated()));
stmt.setString(4, comment.getCreatedBy());
comment.setCommentId(stmt.executeUpdate()); // exception
} catch(Exception ex) {
System.err.println("ProjectRegistration::SQLDAO - addComment");
ex.printStackTrace();
} finally {
try {
if (stmt != …Run Code Online (Sandbox Code Playgroud) 刚进入javascript和knockout.js.我找到了一堆我想要完成的例子.我觉得我可能会忽略一个小的语法错误.我正在尝试通过ajax/json从服务器过滤已经返回的集合(this.tasks).我工作得很好.我想做的是让用户能够在完成和不完整的任务之间切换.
我将代码切换到在tasksFiltered上运行foreach循环."this.done"无论是真还是假.
任务模板
var taskModel = function(id, title, description, done){
var self = this;
this.id = ko.observable(id);
this.title = ko.observable(title);
this.description = ko.observable(description);
this.done = ko.observable(done);
this.showEdit = ko.observable(false);
this.titleUpdate = ko.observable(false);
this.descriptionUpdate = ko.observable(false);
};
Run Code Online (Sandbox Code Playgroud)
页面模型
var pageModelTasks = function(){
var self = this;
this.task_title = ko.observable("");
this.task_description = ko.observable("");
this.task_title_focus = ko.observable(true);
this.tasks = ko.observableArray([]);
this.tasksFiltered = ko.computed(function() {
return ko.utils.arrayFilter(this.tasks, function(Task) {
return Task.done == true;
});
});
// CRUD functions excluded
};
Run Code Online (Sandbox Code Playgroud)
这不起作用.
我正在使用Visual Studio 2013和Cordova CTP 1.1.当我尝试构建项目时,我得到以下神秘错误(为了可读性而添加了换行符):
Error 22
The command ""C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda\vs-cli"
prepare --platform Android --configuration Debug
--projectDir . --projectName "servermon"" exited with code 8.
C:\Users\Nathan\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets 115 5 servermon
Run Code Online (Sandbox Code Playgroud)
我已经尝试过这个问题以及这个问题的解决方案,但这似乎并没有解决问题.我的系统路径似乎包含所有相关内容:
C:\Program Files\Java\jdk1.7.0_60\bin
C:\Users\Nathan\AppData\Local\Android\android-sdk\tools
C:\Users\Nathan\AppData\Local\Android\android-sdk\platform-tools
C:\apache-ant-1.9.3\bin
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\
C:\Program Files (x86)\Windows Live\Shared
C:\Program Files\Microsoft\Web Platform Installer\
C:\Program Files (x86)\nodejs\
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
Run Code Online (Sandbox Code Playgroud)
我还打开了SDK管理器并确保获得最新的(Rev 19)构建工具.系统已经多次重启,我仍然无法构建.有没有人对如何修复此构建问题有任何想法?
编辑:这是我的SDK Manager的屏幕截图

Edit2:这是构建输出
1>------ Build started: Project: servermon, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用LINQ将数据加载到SQL中.当我到达时context.SubmitChanges(),抛出以下异常:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.Linq.dll
Additional information: Violation of UNIQUE KEY constraint 'UQ__SDA_Cont__403B95D755FFB06A'. Cannot insert duplicate key in object 'dbo.SDA_Contracts'. The duplicate key value is (3M).
Run Code Online (Sandbox Code Playgroud)
这是产生错误的代码.我已手动进入数据(通过在调试器中查找订单并查看它).如异常所示,没有重复的条目.
var noDuplicates = query
.GroupBy(x => x.ContractingParty)
.Select(x => x.First());
var duplicates = query
.Select(x => { x.ContractingParty = x.ContractingParty + "-2"; return x; })
.GroupBy(x => x.ContractingParty)
.Where(g => g.Count() > 1)
.Select(x => x.Skip(1).Take(1).Single());
Console.WriteLine(query.Count() + " Total entries");
Console.WriteLine(noDuplicates.Count() + " Unique entries …Run Code Online (Sandbox Code Playgroud)