Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identity Insert problem

Status
Not open for further replies.

Saama5

Programmer
Joined
Jan 6, 2002
Messages
52
Location
US
I am reading ado recordset from access and writing into sql server recordset. But sql server has column which has identity column and I want to send value but it fails. I am using
while(!rs1.EndofFile)
{rs.addnew(sql server recordset)
for(i=0;i<rs1.fieldcount;i++)
{rs.fields.item(...). =rs1.fields.item(...)
}
rs.update
rs1.MoveRecord(access recordset)
}

it fails at rs.update if I start with i as 0(identiy col) but it works with i as 1. I want the same values as they are in Ms access recordset because there are gaps in those identity columns. Like if it is 1 and then 4 it inserts in sql server as 1 and then 2.
Need help
 
You need to issue the statement to allow you to insert specific identity values:
Code:
SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }

Be aware that if you try and insert a duplicate value, many bad things might happen :-( so be careful.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top