473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQL Server Linked Table Insert Record Problem

Bri
Greetings,

I'm having a very strange problem in an AC97 MDB with ODBC Linked tables
to SQL Server 7. The table has an Identity field and a Timestamp field.
The problem is that when a new record is entered, either from a form or
from the table view of the table, when the record gets saved it
immediately displays #DELETED# in all of the fields. However, if I close
the form or table view and reopen the record has in fact been inserted.
The identity field contains the next value in the sequence.

I originally suspected that the record was being deleted by a trigger
(The table is upsized from an Access backend and I picked Triggers for
the Relationships) but I tried disabling the triggers and the symptoms
didn't change.

Generally, if there is something wrong with a linked table you get the
generic error message, "ODBC Call Failed", that doesn't tell you much.
With this, there is no error message.

I've upsized several applications with dozens of tables and this is the
first time I've seen anything like this. Anyone have any ideas on where
to look next?

Thanks,
Bri

Nov 13 '05 #1
8 9199
Well, triggers were a good place to look. If a trigger inserts a row into
another table that has an IDENTITY column, you'll get back the @@IDENTITY
value for that insert, not the initial insert you were trying to do, and that
-will- confuse ODBC. Other than that, I don't know of any specific cause for
the symptom you're having when the table has a TIMESTAMP column.

Oh, just thought of one... Did you change the structure of the table, and not
refresh the link in Access? Access will not know about structural changes
until you refresh the link. Other than that, make sure JET and the ODBC
driver are up to date.

On Thu, 25 Nov 2004 22:09:06 GMT, Bri <no*@here.com> wrote:
Greetings,

I'm having a very strange problem in an AC97 MDB with ODBC Linked tables
to SQL Server 7. The table has an Identity field and a Timestamp field.
The problem is that when a new record is entered, either from a form or
from the table view of the table, when the record gets saved it
immediately displays #DELETED# in all of the fields. However, if I close
the form or table view and reopen the record has in fact been inserted.
The identity field contains the next value in the sequence.

I originally suspected that the record was being deleted by a trigger
(The table is upsized from an Access backend and I picked Triggers for
the Relationships) but I tried disabling the triggers and the symptoms
didn't change.

Generally, if there is something wrong with a linked table you get the
generic error message, "ODBC Call Failed", that doesn't tell you much.
With this, there is no error message.

I've upsized several applications with dozens of tables and this is the
first time I've seen anything like this. Anyone have any ideas on where
to look next?

Thanks,
Bri


Nov 13 '05 #2
Bri
Steve,

Thanks for your reply.

As I said, I tried commenting out all of the Insert triggers and it
still did the same thing. I also tried creating a new ODBC Link after I
tried a relink and its still the same.

Also, when adding a new record from Enterprise Manager everything works
as expected.

The triggers are the ones that the upsizing wizard put in for RI to make
sure that values entered into certain fields exist in the Lookup Table
that the field is related to.

Is there a way to get at the @@IDENTITY value. I am just entering the
record in a bound form.

Thanks
Bri

Steve Jorgensen wrote:
Well, triggers were a good place to look. If a trigger inserts a row into
another table that has an IDENTITY column, you'll get back the @@IDENTITY
value for that insert, not the initial insert you were trying to do, and that
-will- confuse ODBC. Other than that, I don't know of any specific cause for
the symptom you're having when the table has a TIMESTAMP column.

Oh, just thought of one... Did you change the structure of the table, and not
refresh the link in Access? Access will not know about structural changes
until you refresh the link. Other than that, make sure JET and the ODBC
driver are up to date.

On Thu, 25 Nov 2004 22:09:06 GMT, Bri <no*@here.com> wrote:

Greetings,

I'm having a very strange problem in an AC97 MDB with ODBC Linked tables
to SQL Server 7. The table has an Identity field and a Timestamp field.
The problem is that when a new record is entered, either from a form or

from the table view of the table, when the record gets saved it

immediately displays #DELETED# in all of the fields. However, if I close
the form or table view and reopen the record has in fact been inserted.
The identity field contains the next value in the sequence.

I originally suspected that the record was being deleted by a trigger
(The table is upsized from an Access backend and I picked Triggers for
the Relationships) but I tried disabling the triggers and the symptoms
didn't change.

Generally, if there is something wrong with a linked table you get the
generic error message, "ODBC Call Failed", that doesn't tell you much.
With this, there is no error message.

I've upsized several applications with dozens of tables and this is the
first time I've seen anything like this. Anyone have any ideas on where
to look next?

Thanks,
Bri



Nov 13 '05 #3
On Fri, 26 Nov 2004 17:02:21 GMT, Bri <no*@here.com> wrote:
Steve,

Thanks for your reply.

As I said, I tried commenting out all of the Insert triggers and it
still did the same thing. I also tried creating a new ODBC Link after I
tried a relink and its still the same.

Also, when adding a new record from Enterprise Manager everything works
as expected.

The triggers are the ones that the upsizing wizard put in for RI to make
sure that values entered into certain fields exist in the Lookup Table
that the field is related to.

Is there a way to get at the @@IDENTITY value. I am just entering the
record in a bound form.
No, but you're not supposed to have to. Access should get back the @@IDENTITY
value from the insert, and identify the new record with that value. I guess
we know from the symptom that somehow, one of the following things is
occurring:

1. Access is not getting the the @@IDENTITY value back like it's supposed to
(e.g. a driver problem).
2. Access is getting back @@IDENTITY for a different insert (e.g., there's
still a trigger hiding somwehere).

Thanks
Bri

Steve Jorgensen wrote:
Well, triggers were a good place to look. If a trigger inserts a row into
another table that has an IDENTITY column, you'll get back the @@IDENTITY
value for that insert, not the initial insert you were trying to do, and that
-will- confuse ODBC. Other than that, I don't know of any specific cause for
the symptom you're having when the table has a TIMESTAMP column.

Oh, just thought of one... Did you change the structure of the table, and not
refresh the link in Access? Access will not know about structural changes
until you refresh the link. Other than that, make sure JET and the ODBC
driver are up to date.

On Thu, 25 Nov 2004 22:09:06 GMT, Bri <no*@here.com> wrote:

Greetings,

I'm having a very strange problem in an AC97 MDB with ODBC Linked tables
to SQL Server 7. The table has an Identity field and a Timestamp field.
The problem is that when a new record is entered, either from a form or

from the table view of the table, when the record gets saved it

immediately displays #DELETED# in all of the fields. However, if I close
the form or table view and reopen the record has in fact been inserted.
The identity field contains the next value in the sequence.

I originally suspected that the record was being deleted by a trigger
(The table is upsized from an Access backend and I picked Triggers for
the Relationships) but I tried disabling the triggers and the symptoms
didn't change.

Generally, if there is something wrong with a linked table you get the
generic error message, "ODBC Call Failed", that doesn't tell you much.
With this, there is no error message.

I've upsized several applications with dozens of tables and this is the
first time I've seen anything like this. Anyone have any ideas on where
to look next?

Thanks,
Bri



Nov 13 '05 #4
Bri
Steve,

OK, here is some more info:

- I tried it on Access 2000 with SQL 2000 (original was on AC97 and SQL
7) and got the same results.

- Info about the Table:
- Field1 is int and is foreign key to parent table
- Field2 is int and Identity
- Field1 and Field2 are the Primary Key
- Field3 and Field4 are int and are foreign keys to lookup tables
(the triggers, when I have them active, make these required fields, but
I get the #DELETED# whether these triggers are on or not)
- there are several other fields some of which are foreign keys to
lookup tables, others are data of various types
- there is a timestamp field

- If I enter any of the fields in addition to Fields 1-4 then I do not
get the #DELETED# but since all of these fields are optional in the app
I can't be sure any of them will be entered at the time the record is
created (Inserted).

I'm not sure what else I can try.

Bri

Steve Jorgensen wrote:
On Fri, 26 Nov 2004 17:02:21 GMT, Bri <no*@here.com> wrote:

Steve,

Thanks for your reply.

As I said, I tried commenting out all of the Insert triggers and it
still did the same thing. I also tried creating a new ODBC Link after I
tried a relink and its still the same.

Also, when adding a new record from Enterprise Manager everything works
as expected.

The triggers are the ones that the upsizing wizard put in for RI to make
sure that values entered into certain fields exist in the Lookup Table
that the field is related to.

Is there a way to get at the @@IDENTITY value. I am just entering the
record in a bound form.

No, but you're not supposed to have to. Access should get back the @@IDENTITY
value from the insert, and identify the new record with that value. I guess
we know from the symptom that somehow, one of the following things is
occurring:

1. Access is not getting the the @@IDENTITY value back like it's supposed to
(e.g. a driver problem).
2. Access is getting back @@IDENTITY for a different insert (e.g., there's
still a trigger hiding somwehere).

Nov 13 '05 #5
On Mon, 29 Nov 2004 00:05:15 GMT, Bri <no*@here.com> wrote:
Steve,

OK, here is some more info:

- I tried it on Access 2000 with SQL 2000 (original was on AC97 and SQL
7) and got the same results.

- Info about the Table:
- Field1 is int and is foreign key to parent table
- Field2 is int and Identity
- Field1 and Field2 are the Primary Key Aha! - Field3 and Field4 are int and are foreign keys to lookup tables


You are using an IDENTITY field as -part- of the key, not the whole key. I've
never seen anyone try that, I'm not sure why you would, and I wouldn't expect
DAO or ADO to be smart enough to know how to handle it.

Since the IDENTITY field must be unique all by itelf, why are you including
another field as part of the primary key?

Nov 13 '05 #6
Bri
Steve,

My thinking was that since Field1 is the PK of the Parent table that it
should be included in the Child PK. Otherwise, how do I create a
relationship between these tables?

OK, I changed the PK to be only the Identity field and the #DELETED#
problem went away. I now have the new problem of having no relationship
between the Parent and Child table. I suppose I can create a Trigger to
enforce this, but I wonder if that will effect performance since the
relationship is no longer indexed. Or will a separate index on the
Parent foreign key be sufficient? Or am I thinking too much in terms of
what is needed in a relationship in an Access BE? I'd rather have the
Engine level enforce the relationship than have to 'roll my own', but if
it is the only way to do it in SQL Server, then that's what I'll do.

Thanks,
Bri

Steve Jorgensen wrote:
On Mon, 29 Nov 2004 00:05:15 GMT, Bri <no*@here.com> wrote:

Steve,

OK, here is some more info:

- I tried it on Access 2000 with SQL 2000 (original was on AC97 and SQL
7) and got the same results.

- Info about the Table:
- Field1 is int and is foreign key to parent table
- Field2 is int and Identity
- Field1 and Field2 are the Primary Key


Aha!
- Field3 and Field4 are int and are foreign keys to lookup tables

You are using an IDENTITY field as -part- of the key, not the whole key. I've
never seen anyone try that, I'm not sure why you would, and I wouldn't expect
DAO or ADO to be smart enough to know how to handle it.

Since the IDENTITY field must be unique all by itelf, why are you including
another field as part of the primary key?

Nov 13 '05 #7
On Mon, 29 Nov 2004 18:49:14 GMT, Bri <no*@here.com> wrote:
Steve,

My thinking was that since Field1 is the PK of the Parent table that it
should be included in the Child PK. Otherwise, how do I create a
relationship between these tables?


That's simply not true. Often, when surrogate (e.g. IDENTITY or Autonumber)
keys are -not- used, a foreign key is used as part of the many-side table's
primary key because the key would not be unique otherwise, but that has
nothing to do with the requirements for a foreign key, it has to do with how
unique records are identified in the many-side table.

For instance, if I formulate invoices and lines as follows, I need the foreign
key in the invoice_line table because line number is not unique by itself...

invoice
* invoice_num
customer_name

invoice_line
* invoice_num
* line_num (1 to n) for each invoice.
line_descrip
line_qty
unit_cost

On the other hand, if I use surrogate keys as follows, I can create a foreign
key relationship just fine, and the foreign key field is not part of the
primary key of invoice_line...

invoice
* invoice_id (IDENTITY)
invoice_num
customer_name

invoice_line
* invoice_line_id
invoice_id (fk)
line_descrip
line_qty
unit_cost
Nov 13 '05 #8
Bri
Steve,

Now that you point it out, I realize I knew that all along, but had
somehow got caught up in the habit of including the FK as I usually do
parent-child relationships using the first method you showed. In this
case, there is a unique field in the child table that would have made a
perfect PK if it wasn't for the small detail of it not being determined
until some time after the initial record is created. That's why I
created the Identity field.

Thanks for all your help here. The symptoms certainly didn't make the
cause of the problem obvious.

Bri

Steve Jorgensen wrote:
On Mon, 29 Nov 2004 18:49:14 GMT, Bri <no*@here.com> wrote:

Steve,

My thinking was that since Field1 is the PK of the Parent table that it
should be included in the Child PK. Otherwise, how do I create a
relationship between these tables?

That's simply not true. Often, when surrogate (e.g. IDENTITY or Autonumber)
keys are -not- used, a foreign key is used as part of the many-side table's
primary key because the key would not be unique otherwise, but that has
nothing to do with the requirements for a foreign key, it has to do with how
unique records are identified in the many-side table.

For instance, if I formulate invoices and lines as follows, I need the foreign
key in the invoice_line table because line number is not unique by itself...

invoice
* invoice_num
customer_name

invoice_line
* invoice_num
* line_num (1 to n) for each invoice.
line_descrip
line_qty
unit_cost

On the other hand, if I use surrogate keys as follows, I can create a foreign
key relationship just fine, and the foreign key field is not part of the
primary key of invoice_line...

invoice
* invoice_id (IDENTITY)
invoice_num
customer_name

invoice_line
* invoice_line_id
invoice_id (fk)
line_descrip
line_qty
unit_cost


Nov 13 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
26
by: David W. Fenton | last post by:
A client is panicking about their large Access application, which has been running smoothly with 100s of thousands of records for quite some time. They have a big project in the next year that will...
6
by: Larry Johnson | last post by:
I have two similar SQL Server databases each with a table named Payments. PaymentID is an identity field and the primary, unique, key in both tables. There is one other key but it is not unique. ...
0
by: crypto_solid via AccessMonster.com | last post by:
I have been using a SQL database with a VB5 frontend for about 5 years. Works well. Unfortunately I don't have access to the source code. I was tasked with implementing a "job entry" application...
2
by: Charles Wilt | last post by:
I have a IBM iSeries (aka AS-400) running v5r3 of OS/400 that I access via a linked server from SQL Server 2000. The following select works fine: select * from...
2
by: Jim Devenish | last post by:
I am developing an Access front-end linked to SQL Server back-end. In the triggers I raise an error as in: RAISERROR 44447 'The record cannot be changed. RI rules require a related record in...
20
by: TC | last post by:
I need an automated procedure to copy data from an Access table to a SQL Server table. Speed is important. What is the recommended technique? I can export the data from Access, copy it via FTP,...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
4
by: Tonio Tanzi | last post by:
I have the following problem in a Win 2000 Server + SQL Server 2000 environment and I hope somewhat can help me to resolve it (after many days of useless attempts I am desperate). In my database...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.