identity

How do I insert entities with Linq To SQL where I wish to specify their identities - eg, pre-populating tables on DB creation?

I'm engaged in writing a product using LinqToSql for data-access. While we're rapidly developing, the model changes often. This means we dump and reload the database lots while developing. Thus, overhead is involved to recreate baseline data each time. A process that restores a DB backup is not useful, because we would need to update...

Why would @@IDENTITY or SCOPE_IDENTITY() be DBNull?

(resolved: see bottom) I have the following code snippet: Protected Sub SqlDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Inserted affected = CInt(DirectCast(e.Command.Parameters("@affected"), IDbDataParameter).Value) newID = CInt(DirectCas...

what user account does my IIS hosted wcf service run under?

Hi, what user account does my .net wcf service run under when I am hosting it in iis 7? Is it the IUSR_machine account? What is the easiest way for me to run under a different account? (just for this service, don't want other things hosted in my IIS to be effected). ...

Sql 2005 data migration

I have the same database running on two different machines. The DB's make extensive use of Identity columns, and the tables have clashed pretty horribly. I now want to merge these two together before sorting out the undelying issue which I may do by A) Using GUIDs (unweildy but works everywhere) B) Assigning Identity ranges, kind of na...

Implementations of single sign on, multiple profile?

My employer is considering implementing a single-account, multiple profile system across their various web properties. The thinking is that SSO will be more convenient for users, but they might not want their activities on a dating site to be associated with their contributions to a forum on another site. I'm very cautious about this ap...

trigger insertions into same table

I have many tables in my database which are interrelated. I have a table (table one) which has had data inserted and the id auto increments. Once that row has an ID i want to insert this into a table (table three) with another set of ID's which comes from a form(this data will also be going into a table, so it could from from that table)...

How to increment (or reserve) IDENTITY value in SQL Server without inserting into table

Is there a way to reserve or skip or increment value of identity column? I Have two tables joined in one-to-one relation ship. First one has IDENTITY PK column, and second one int PK (not IDENTITY). I used to insert in first, get ID and insert in second. And it works ok. Now I need to insert values in second table without inserting in...

T-SQL: @@IDENTITY, SCOPE_IDENTITY(), OUTPUT and other methods of retrieving last identity

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...

Auto incrementing ID value

I have an HSQLDB database with a generated ID and I want the auto-incrementing values to always be above 100,000. Is this possible with HSQLDB? Is this possible with any database? ...

User.Identity.Name

I've seen this question posted similarly in the past, I was hoping someone can point me in the right direction, the User.Identity.Name class returns the domain login. Which class exposes the actual name? For user "John Doe" who logs into the web application supplying my_domain\jdoe User.Identity.Name - Returns : *my_domain\jdoe* Sy...

Moving from ADFS to the Geneva Framework

My company is in need of a federated identity solution, and being a Microsoft shop, we're looking to use MS technologies to accomplish this goal. We don't have Server 2008 or .NET 3.5 in production, so we're limited to a .NET 2.0/Server 2003-based solution. This means (in terms of a federated identity solution), Active Directory Federa...

How do I MANUALLY set an Identity field in LINQ-To-SQL (IDENTITY INSERT)

I have a table that normally, upon insert, the auto-key will increment. But, there are some instances when we want to set the ID (as would easily be done with "IDENTITY INSERT" in SQL). Is there a way to accomplish this with LINQ to SQL? Thanks, ...

Bulk modification of unique ids in SQL Server

[This is a bit of an unusual problem, I know...] What I need is a script that will change every unique id value to new one in our database. The problem is that we have configuration tables that can be exported between instances of our software which is id-sensitive (clobbering existing ids). Years ago, we set up a "wide-enough" id gap ...

problem with asp.net gridview

Hello all, I have problem with gridview deleting.I have table name Doctor with Id,Name,Address,Phone.Id is auto generated field.After adding data when i am displaying in gridview then if delete any id from gridview Again then if i add any new details from the form its starting from the new number.I mean if i delete the last id no 5 then ...

what type of database record id to use: long or guid ?

Hi In recent years I was using MSSQL databases, and all unique records in tables has the ID column type of bigint (long). It is autoincrementing and generally - works fine. Currently I am observing people prefer to use GUIDs for record's identity. Does it make sense to swap bigint to guid for unique record id? I think it doesn't make...

How Do You Tell What Next Identity Column Will Be?

Is there a tsql query to tell what SQL server identity column value it expects to use for the next row insert? Edited to add: I deleted and recreated a table with [personID] [int] IDENTITY(1,1) NOT NULL as part of my CREATE TABLE command. I've also attempted to reseed identity columns while removing all information in that table a...

Generic identity function for use with type inference

Hi I was wondering if it is possible, as my 5 minutes of experimentation proved fruitless. I hoped it would be as easy as: T Identity<T>(T t) { return t; } But this fails to compile on generic methods taking Func parameters. Eg OrderBy. Even specifying type parameters (which is exactly what I want to avoid!), it fails to compile. ...

How can I retrieve the identities of rows that were inserted through insert...select?

I am inserting records through a query similar to this one: insert into tbl_xyz select field1 from tbl_abc Now I would like to retreive the newly generated IDENTITY Values of the inserted records. How do I do this with minimum amount of locking and maximum reliability? ...

Advice Please: SQL Server Identity vs Unique Identifier keys when using Entity Framework

I'm in the process of designing a fairly complex system. One of our primary concerns is supporting SQL Server peer-to-peer replication. The idea is to support several geographically separated nodes. A secondary concern has been using a modern ORM in the middle tier. Our first choice has always been Entity Framework, mainly because th...

Primarykey violation in restored database

Hi, I set up the transactional replication(not updatable subscriber) between sql server 2005 database. The tables in published database have identity columns. The tables were replicated without problem. But when I back up and restore the subscriber database, I could not insert row in a table which contains identity increment field and i...