[HttpPost]
public void InsertOrUpdateDirector(Director director)
{
int idReturned = 0;
string query = null;
myConnection.Open();
if (director.Operation == 'I')
{
query = "INSERT...";
}
else if (director.Operation == 'U')
{
query = "UPDATE ...";
}
var cmd = new SqlCommand(query, myConnection);
cmd.ExecuteNonQuery();
myConnection.Close();
idReturned = "???";
return idReturned;
}
Run Code Online (Sandbox Code Playgroud)
我只是想在insert语句之后返回新创建的ID.我该怎么做呢?
基本上,如果参数以NULL形式出现,我想将其作为数据库NULL发送到数据库.因此(查看下面代码中的注释):
[HttpPost]
public void UpdateTitle(Title title)
{
string query = null;
string description = "";
string episodeAKA = "";
if (title.Description != null)
{
description = "'" + title.Description + "'";
}
else
{
//here's where description should be a DBNULL.
}
if (title.EpisodeAKA == null)
{
title.EpisodeAKA = "NULL";
}
myConnection.Open();
if (title.Operation == 'U')
{
query = "UPDATE dbo.AWD_Titles SET AwardStatusId = " + title.AwardStatus + ", Description = " + description + ", IsVerified = " + …Run Code Online (Sandbox Code Playgroud) 串:
https://company.zendesk.com/api/v2/tickets/33126.json
Run Code Online (Sandbox Code Playgroud)
我需要33126号.
提取这个数字的最佳方法是什么?
请参阅以下代码中的评论:
$('#btnDelete').on('click', function()
{
var treeView = $("#treeview").data("kendoTreeView");
var userId = $('#user_id').val();
$('#treeview').find('input:checkbox:checked').each(function()
{
debugger;
var li = $(this).closest(".k-item")[0];
var notificationId = treeView.dataSource.getByUid(li.getAttribute('data-uid')).ID;
if (notificationId == undefined)
{
//if the notification ID is "undefined" here, I want the ".EACH" 'loop' to continue to the next item.
}
$.ajax(
{
url: '../api/notifications/deleteNotification?userId=' + userId + '¬ificationId=' + notificationId,
type: 'DELETE'
}).done(function()
{
var treeview = $("#treeview").data("kendoTreeView");
treeview.destroy();
CreateNotificationTree(userId);
console.log('Delete successful.');
}).fail(function(jqXHR, status, error)
{
console.log("Error : " + error);
});
treeView.remove($(this).closest('.k-item')); …Run Code Online (Sandbox Code Playgroud) 这不起作用:
DBCC CHECKIDENT('[DMS].[dbo].[ImportedFiles]', RESEED, 0)
Run Code Online (Sandbox Code Playgroud)
插入下一条记录后,我希望种子为0而不是1.
我试过这个,但功能不喜欢它:
DBCC CHECKIDENT('[DMS].[dbo].[ImportedFiles]', RESEED, -1)
DBCC CHECKIDENT('[DMS].[dbo].[ImportedFiles]', RESEED, '-1')
Run Code Online (Sandbox Code Playgroud)
如何重置表的种子,以便下一个记录是零?(0)?