Hi,
How can I set IDENTITY_INSERT to ON on the mssql server via C#, and turn
it OFF again, after I have made my insert?
Cause right now I can't sinde one of the Column's have IDENTITY on.
Kind Regards
Mikael Syska 4 19373
"Mikael Syska" <ne**********@s yska.dk> wrote in message
news:Om******** ******@tk2msftn gp13.phx.gbl... Hi,
How can I set IDENTITY_INSERT to ON on the mssql server via C#, and turn it OFF again, after I have made my insert?
Cause right now I can't sinde one of the Column's have IDENTITY on.
Assuming you're using SQL Server 2000, just place
SET IDENTITY_INSERT <tablename> ON
at the beginning of your SQL and
SET IDENTITY_INSERT <tablename> OFF
at the end
Kind a new to C#, how do I devide that???
if my SqlCommand look like this:
thisCommand = new SqlCommand("INS ERT INTO [regGroups] VALUES (3, 'det
kan man godt', 'desc', 0, '10-10-2004 05:47:17')", thisConnection) ;
Mark Rae wrote: "Mikael Syska" <ne**********@s yska.dk> wrote in message news:Om******** ******@tk2msftn gp13.phx.gbl...
Hi,
How can I set IDENTITY_INSERT to ON on the mssql server via C#, and turn it OFF again, after I have made my insert?
Cause right now I can't sinde one of the Column's have IDENTITY on.
Assuming you're using SQL Server 2000, just place
SET IDENTITY_INSERT <tablename> ON
at the beginning of your SQL and
SET IDENTITY_INSERT <tablename> OFF
at the end
I just created a Stored Procedure...... ..
Mikael Syska wrote: Kind a new to C#, how do I devide that???
if my SqlCommand look like this: thisCommand = new SqlCommand("INS ERT INTO [regGroups] VALUES (3, 'det kan man godt', 'desc', 0, '10-10-2004 05:47:17')", thisConnection) ;
Mark Rae wrote:
"Mikael Syska" <ne**********@s yska.dk> wrote in message news:Om******** ******@tk2msftn gp13.phx.gbl...
Hi,
How can I set IDENTITY_INSERT to ON on the mssql server via C#, and turn it OFF again, after I have made my insert?
Cause right now I can't sinde one of the Column's have IDENTITY on. Assuming you're using SQL Server 2000, just place
SET IDENTITY_INSERT <tablename> ON
at the beginning of your SQL and
SET IDENTITY_INSERT <tablename> OFF
at the end
Mikael Syska wrote: Kind a new to C#, how do I devide that???
if my SqlCommand look like this: thisCommand = new SqlCommand("INS ERT INTO [regGroups] VALUES (3, 'det kan man godt', 'desc', 0, '10-10-2004 05:47:17')", thisConnection) ;
new SqlCommand("SET IDENTITY_INSERT ON;INSERT INTO... ;SET IDENTITY_INSERT
OFF", ....);
Frans.
Mark Rae wrote: "Mikael Syska" <ne**********@s yska.dk> wrote in message news:Om******** ******@tk2msftn gp13.phx.gbl...
Hi,
How can I set IDENTITY_INSERT to ON on the mssql server via C#, and turn it OFF again, after I have made my insert?
Cause right now I can't sinde one of the Column's have IDENTITY on.
Assuming you're using SQL Server 2000, just place
SET IDENTITY_INSERT <tablename> ON
at the beginning of your SQL and
SET IDENTITY_INSERT <tablename> OFF
at the end
--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: For example John Smith |
last post by:
I'm doing a data transfer from Access to SQL Server, I wish to keep the
identity column (autonumber) values as all the data is already related. I
tried the first table append query including the identity column, it worked.
Was this fluke? Will it always work? I was under the impression that I would
have to issue a "set identity_insert on" before doing this. The SQL database
will have absolutely no data before the transfer routines are run.
|
by: Edward |
last post by:
Access 2k -> SQL Server 2k
My client has an app that is A2k FE with A2k BE. They have asked me
to move the BE to SQL Server.
I have a bit of experience with SQL Server, and I'm happy with
scripting the database etc.
However, when it comes time to move the data itself, I have a teensy
little concern.
|
by: drs |
last post by:
Hi, I am having a problem with IDENTITY_INSERT command with MSDE 2000 (ADO
2.8) in that I cannot insert a specific value to an identity field. (lines
below with >>> are code lines. I am using Python, but the syntax should be
about the same as VBScript)
First, I create an ADO Connection and create my table.
|
by: Christopher Lusardi |
last post by:
How can I fix this? When I do the below I get the error message:
"Cannot insert explict value for identity column in table
'Employees' when IDENTITY_INSERT is set to OFF."
To get this message, I click the Add button to add a new row to the
database, and then I click the Update button to save the new database
to the external memory.
The methods I used are below.
|
by: teddysnips |
last post by:
SQL Server 2000 (DDL below)
If I try to run this code in QA:
SET IDENTITY_INSERT tblAdminUsers ON
INSERT INTO tblAdminUsers
(fldUserID,
fldUsername,
fldPassword,
fldFullname,
| |
by: csharpa |
last post by:
I have 2 tables Patient(parent) , Battery(Child). when i gave input to it, in parent table the new record will be added but in child table the new record will not be added although I'm sending the FK to child table and also i set the automatic identity generator for it. why it will not add the new record to child table?
string connection = "Data Source=.\\SQLEXPRESS;AttachDbFilename=\"C:\\Program Files\\Microsoft SQL...
|
by: Sally1053 |
last post by:
I have created a procedure which start by fecthing data from DB-X and put in into the temporary memory. what im trying to do now is to take data from temporary memory insert/update DB-Y.
But now I get this ERROR Msg 512, Level 16, State 1, Line 33
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
HERE IS MY PROCEDURE
DECLARE...
|
by: Guineapig1980 |
last post by:
Hi all
I am trying to copy data from one database server to another. I only
want to copy one table's data, not the entire database. The part that
I am having trouble with is connecting from one database server and
connect to another then telling it to insert into the second database
server.
Not sure if this is how it works.
|
by: ll |
last post by:
Hi,
I recently detached and subsequently reattached a database, and now
I've had to go back to each table and re-establish the primary keys,
as well as the identity="yes" where needed. I am currently getting
the following error message, although this table's identity_insert is
set to ON ("yes").
I'm currently re-checking all other tables to see if they would
perhaps impact this.
Would there be anything else I could do at this point? ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |