Unix Technical Forum

Insert failed

This is a discussion on Insert failed within the MS SQL ODBC forums, part of the Microsoft SQL Server category; --> I am running the code below on two similar tables. They both have an identity insert field and both ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > MS SQL ODBC

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 08:50 PM
Mark A. Sam
 
Posts: n/a
Default Insert failed

I am running the code below on two similar tables. They both have an
identity insert field and both have a timestamp. The first routine labeled
Insert Product Materials runs fine, the second, Insert products mateirals,
fails.
This is the error:

error 3155: ODBC -Insert on linked table 'Customer ST Products Tasks '
Failed.

****************************************
'Insert product's materials
strSQL = "INSERT INTO [Customer ST Products Materials] ( custProdID,
prodmatType, prodmatManuf, prodmatDesc, prodmatNotes, EntryDate,
TestRecord ) " & _
"SELECT " & newCustProdID & " AS custProdID, prodmatType,
prodmatManuf, prodmatDesc, prodmatNotes, #" & setEntryTime & "# AS
EntryDate, " & bolTestRecord & " AS TestRecord " & _
"FROM [Customer ST Products Materials] " & _
"WHERE ((([custProdID])=" & rstProds![CustProdID] & "));"

Debug.Print strSQL

CurrentDb.Execute strSQL

'Insert product's tasks
strSQL = "INSERT INTO [Customer ST Products Tasks] ( custProdID, prodTask,
[Benchmark Time], [Avg Time], EntryDate, TestRecord ) " & _
"SELECT " & newCustProdID & " AS custProdID, prodTask,
[Benchmark Time], [Avg Time], #" & setEntryTime & "# AS EntryDate, " &
bolTestRecord & " AS TestRecord " & _
"FROM [Customer ST Products Tasks] " & _
"WHERE ((([custProdID])=" & rstProds![CustProdID] & "));"


Debug.Print strSQL

CurrentDb.Execute strSQL

****************************************

If I open the table 'Customer ST Products Tasks ' I cannot enter a record.
I get this error:

ODBC -Insert on linked table 'Customer ST Products Tasks ' Failed.
[Microsoft][ODBS SQL Server Driver][SQL Server]Explicit value must be
specified for identity column in table 'Customer ST Products Tasks' when
IDENTIY_INSERT is set to ON (#545)

but if i open table 'Customer ST Products Materials' directly I can enter a
new record.

There are several other tables in this procedure with Indentity insert
fields and they aren't giving me any trouble.

Any help will be appreciated.

God Bless,

Mark A. Sam




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 08:50 PM
Sue Hoegemeier
 
Posts: n/a
Default Re: Insert failed

It's hard to give you more specifics without the DDL for the
tables, the connection settings, etc but the error is pretty
much what it is telling you: the connection sets an
identity_insert on for the table and the insert command does
not specify a value. If you aren't specifying a value for
the identity column, then you need to turn identity_insert
off for that insert statement. You can find more information
in books online under the topic: SET IDENTITY_INSERT

-Sue

On Fri, 5 Aug 2005 15:28:30 -0400, "Mark A. Sam"
<msam@Plan-It-Earth.Net> wrote:

>I am running the code below on two similar tables. They both have an
>identity insert field and both have a timestamp. The first routine labeled
>Insert Product Materials runs fine, the second, Insert products mateirals,
>fails.
>This is the error:
>
>error 3155: ODBC -Insert on linked table 'Customer ST Products Tasks '
>Failed.
>
>****************************************
> 'Insert product's materials
> strSQL = "INSERT INTO [Customer ST Products Materials] ( custProdID,
>prodmatType, prodmatManuf, prodmatDesc, prodmatNotes, EntryDate,
>TestRecord ) " & _
> "SELECT " & newCustProdID & " AS custProdID, prodmatType,
>prodmatManuf, prodmatDesc, prodmatNotes, #" & setEntryTime & "# AS
>EntryDate, " & bolTestRecord & " AS TestRecord " & _
> "FROM [Customer ST Products Materials] " & _
> "WHERE ((([custProdID])=" & rstProds![CustProdID] & "));"
>
> Debug.Print strSQL
>
> CurrentDb.Execute strSQL
>
> 'Insert product's tasks
> strSQL = "INSERT INTO [Customer ST Products Tasks] ( custProdID, prodTask,
>[Benchmark Time], [Avg Time], EntryDate, TestRecord ) " & _
> "SELECT " & newCustProdID & " AS custProdID, prodTask,
>[Benchmark Time], [Avg Time], #" & setEntryTime & "# AS EntryDate, " &
>bolTestRecord & " AS TestRecord " & _
> "FROM [Customer ST Products Tasks] " & _
> "WHERE ((([custProdID])=" & rstProds![CustProdID] & "));"
>
>
> Debug.Print strSQL
>
> CurrentDb.Execute strSQL
>
>****************************************
>
>If I open the table 'Customer ST Products Tasks ' I cannot enter a record.
>I get this error:
>
>ODBC -Insert on linked table 'Customer ST Products Tasks ' Failed.
>[Microsoft][ODBS SQL Server Driver][SQL Server]Explicit value must be
>specified for identity column in table 'Customer ST Products Tasks' when
>IDENTIY_INSERT is set to ON (#545)
>
>but if i open table 'Customer ST Products Materials' directly I can enter a
>new record.
>
>There are several other tables in this procedure with Indentity insert
>fields and they aren't giving me any trouble.
>
>Any help will be appreciated.
>
>God Bless,
>
>Mark A. Sam
>
>
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 08:50 PM
Mark A. Sam
 
Posts: n/a
Default Re: Insert failed

Sue,

This doesn't make sense. The Identity Insert is a primary key intended to
be an auto number. The value should be assigned. It only happend on one
table. I have other tables with the same fields without a problem. This
happened to me a couple years ago when I first changed the tables from
Access to SQL Server. I don't recall if this table was the problem, but I
worked around it someohow, but I can't remember that either.

I'm working with an .mdb and linked tables, and not a project. Access
should handle this.

I guess I'll have to plan around with it.

Thanks and God Bless,

Mark



"Sue Hoegemeier" <Sue_H@nomail.please> wrote in message
news:84idf1lpivjlhstmqq64vf8kn8up3tv4dv@4ax.com...
> It's hard to give you more specifics without the DDL for the
> tables, the connection settings, etc but the error is pretty
> much what it is telling you: the connection sets an
> identity_insert on for the table and the insert command does
> not specify a value. If you aren't specifying a value for
> the identity column, then you need to turn identity_insert
> off for that insert statement. You can find more information
> in books online under the topic: SET IDENTITY_INSERT
>
> -Sue
>
> On Fri, 5 Aug 2005 15:28:30 -0400, "Mark A. Sam"
> <msam@Plan-It-Earth.Net> wrote:
>
> >I am running the code below on two similar tables. They both have an
> >identity insert field and both have a timestamp. The first routine

labeled
> >Insert Product Materials runs fine, the second, Insert products

mateirals,
> >fails.
> >This is the error:
> >
> >error 3155: ODBC -Insert on linked table 'Customer ST Products Tasks '
> >Failed.
> >
> >****************************************
> > 'Insert product's materials
> > strSQL = "INSERT INTO [Customer ST Products Materials] ( custProdID,
> >prodmatType, prodmatManuf, prodmatDesc, prodmatNotes, EntryDate,
> >TestRecord ) " & _
> > "SELECT " & newCustProdID & " AS custProdID, prodmatType,
> >prodmatManuf, prodmatDesc, prodmatNotes, #" & setEntryTime & "# AS
> >EntryDate, " & bolTestRecord & " AS TestRecord " & _
> > "FROM [Customer ST Products Materials] " & _
> > "WHERE ((([custProdID])=" & rstProds![CustProdID] & "));"
> >
> > Debug.Print strSQL
> >
> > CurrentDb.Execute strSQL
> >
> > 'Insert product's tasks
> > strSQL = "INSERT INTO [Customer ST Products Tasks] ( custProdID,

prodTask,
> >[Benchmark Time], [Avg Time], EntryDate, TestRecord ) " & _
> > "SELECT " & newCustProdID & " AS custProdID, prodTask,
> >[Benchmark Time], [Avg Time], #" & setEntryTime & "# AS EntryDate, " &
> >bolTestRecord & " AS TestRecord " & _
> > "FROM [Customer ST Products Tasks] " & _
> > "WHERE ((([custProdID])=" & rstProds![CustProdID] & "));"
> >
> >
> > Debug.Print strSQL
> >
> > CurrentDb.Execute strSQL
> >
> >****************************************
> >
> >If I open the table 'Customer ST Products Tasks ' I cannot enter a

record.
> >I get this error:
> >
> >ODBC -Insert on linked table 'Customer ST Products Tasks ' Failed.
> >[Microsoft][ODBS SQL Server Driver][SQL Server]Explicit value must be
> >specified for identity column in table 'Customer ST Products Tasks' when
> >IDENTIY_INSERT is set to ON (#545)
> >
> >but if i open table 'Customer ST Products Materials' directly I can enter

a
> >new record.
> >
> >There are several other tables in this procedure with Indentity insert
> >fields and they aren't giving me any trouble.
> >
> >Any help will be appreciated.
> >
> >God Bless,
> >
> >Mark A. Sam
> >
> >
> >

>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 08:50 PM
Mark A. Sam
 
Posts: n/a
Default Re: Insert failed

This issue cleared up.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 09:08 PM
saifblore
 
Posts: n/a
Default Re: Insert failed


Could you please let me know what have you done for the solution?


Mark A. Sam wrote:
> *This issue cleared up. *




--
saifblore
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1774985.html

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 09:11 PM
csgraham74
 
Posts: n/a
Default Re: Insert failed


saifblore wrote:
> *Could you please let me know what have you done for the solution? *


Hi there did you ever find a solution to the insert issue regardsing
ODBC linked table.

any help appreciated

CG



--
csgraham74
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1774985.html

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com