identity

How do I reset an increment identity's starting value in SQL Server

三世轮回 提交于 2019-12-17 17:26:04
问题 I would like to have a nice template for doing this in development. How do I reset an increment identity's starting value in SQL Server? 回答1: DBCC CHECKIDENT('TableName', RESEED, 0) 回答2: Just a word of warning with: DBCC CHECKIDENT (MyTable, RESEED, 0) If you did not truncate the table, and the identity column is the PK, you will get an error when reaching pre-existing identites. For example, you have identities (3,4,5) in the table already. You then reset the identity column to 1. After the

How do I get the Current User identity for a VPN user in a Windows forms app?

南笙酒味 提交于 2019-12-17 16:49:08
问题 We're currently developing a Windows Smartclient that needs to authenticate users using their AD group membership. We now have a requirement for some users to connect over VPN. Is there any way I can get the AD account identity and groups from the VPN login? WindowsIdentity.GetCurrent() returns the local user account rather than their VPN account information. The local account name is different that the AD account used for the VPN connection. i.e the user is on their home PC, and connecting

Primary key from inserted row jdbc?

亡梦爱人 提交于 2019-12-17 15:46:34
问题 Is there a cross database platform way to get the primary key of the record you have just inserted? I noted that this answer says that you can get it by Calling SELECT LAST_INSERT_ID() and I think that you can call SELECT @@IDENTITY AS 'Identity'; is there a common way to do this accross databases in jdbc? If not how would you suggest I implement this for a piece of code that could access any of SQL Server, MySQL and Oracle? 回答1: Copied from my code: pInsertOid = connection.prepareStatement

ExpireTimeSpan ignored after regenerateIdentity / validateInterval duration in MVC Identity (2.0.1)

你离开我真会死。 提交于 2019-12-17 07:07:31
问题 Been scratching my head all day on this one. I'm trying to set up "very long" login sessions in MVC Identity 2.0.1. (30 days). I use the following cookie startup: app.UseCookieAuthentication(new CookieAuthenticationOptions { SlidingExpiration = true, ExpireTimeSpan = System.TimeSpan.FromDays(30), AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/My/Login"), CookieName = "MyLoginCookie", Provider = new CookieAuthenticationProvider {

SQLServer IDENTITY Column with text

ⅰ亾dé卋堺 提交于 2019-12-17 06:14:42
问题 How would I create an IDENTITY column in SQLServer with text in the column? Example: ABCD-987065 ABCD-987066 ABCD-987067 回答1: In addition to the other answers, you could create a computed column on the table to provide what you are asking for. CREATE TABLE dbo.MyTable ( Id int NOT NULL PRIMARY KEY, CombinedId AS 'ABCD-' + CAST(Id as varchar(16)) ) Or: CREATE TABLE dbo.MyTable ( Id int NOT NULL PRIMARY KEY, PrefixField varchar(16), CombinedId AS PrefixField + CAST(Id as varchar(16)) ) (Your

SQL拆分字段

混江龙づ霸主 提交于 2019-12-17 05:02:20
拆分字段与合并字段是字符串处理常见的两个问题,下面将针对实例进行分析求解。 问题:將字符串拆分成記錄集 原表Table1(id int identity(1,1),name varchar(100)) id name ------------------- 1 'a,b,c' 2 'e,f' 希望得到结果: id name ----------- 1 'a' 1 'b' 1 'c' 2 'e' 2 'f' 一、首先我们利用最原始的方法进行求解,即通过逐条循环来实现。 create table #a(id int identity(1,1),name varchar(100)) insert #a(name) select 'a,b,c' union all select 'd,e,f' union all select 'g,h' 1.利用游标 DECLARE @id int,@name varchar(100) create table #b(id int,name varchar(100)) DECLARE a_cursor CURSOR FOR SELECT id, name FROM #a ORDER BY id OPEN a_cursor FETCH NEXT FROM a_cursor INTO @id, @name WHILE @@FETCH_STATUS = 0

@@IDENTITY, SCOPE_IDENTITY(), OUTPUT and other methods of retrieving last identity

岁酱吖の 提交于 2019-12-17 04:45:30
问题 I have seen various methods used when retrieving the value of a primary key identity field after insert. declare @t table ( id int identity primary key, somecol datetime default getdate() ) insert into @t default values select SCOPE_IDENTITY() --returns 1 select @@IDENTITY --returns 1 Returning a table of identities following insert: Create Table #Testing ( id int identity, somedate datetime default getdate() ) insert into #Testing output inserted.* default values What method is proper or

Asp.net Identity password hashing

烈酒焚心 提交于 2019-12-17 03:57:32
问题 The new ASP.net Identity project has brought some useful code and interfaces for website security. To implement a custom system using the interfaces (instead of using the standard Entity Framework implementation included in the MVC 5 template) an IPasswordHasher is required. IPasswordHasher interface in ASP.net Identity namespace Microsoft.AspNet.Identity { public interface IPasswordHasher { string HashPassword(string password); PasswordVerificationResult VerifyHashedPassword(string

I need to save the User Name and email address separately. I am am having an issue with logging into the site after the user is registered

*爱你&永不变心* 提交于 2019-12-16 18:04:20
问题 I am creating a new ASP.NET Core (2.2) WebSite. By default, the UserName and Email Address is the same thing. I want to have them be different. The issue comes in when I try to log that user back into the web page. I scaffolded the register Identity page and made some simple changes to the Code behind and also the Razor page itself (see below). I did also scaffold the login page, but I don't think that I need to make any changes there, because I am ok with folks logging in using their email

Controller Action not triggered - Simple Project - ASP.NET MVC CORE 2.0

无人久伴 提交于 2019-12-14 03:15:39
问题 I have a very simple web application, where I try to let people register a user. Therefore, I try to save user-registration data to Entity Framework, but with no luck. For some reason, IActionResult RegisterUser isn't triggered when submitting a form (I tried setting breakpoints, nothing happened). Can anyone detect why? Startup.cs public class Startup { public void ConfigureServices(IServiceCollection services) { var connection = @"Server=(localdb)\mssqllocaldb;Database=APIExercise2;Trusted