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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC-Update on a linked table failed

Status
Not open for further replies.

Arnold

Programmer
Jul 2, 1999
32
NL
I have an Access 97 database that I am upgrading to utilize a SQL Server 7.0 backend and an Access 2000 front end. First, I am upsizing the Access 97 database to Access 2000 and then running the Upsizing Wizard to create the Access 2000 database with linked tables to the SQL Server. When I upsize the backend to SQL Server, I check the following attributes to upsize: indexes, validation rules, defaults, and table relationships using triggers(I currently have update and delete cascading selected and I enforce referential integrity). I let the wizard add timestamp fields and I only upsize the table structure. I later import the data without any problems. I then choose the option to link SQL Server tables to the existing application. 99% of the program runs fine. I use unbounded forms that I created in Access to manipulate the data. The vast majority of data adds, edits, and deletes are done through the use of recordsets with an SQL statement as the source for the recordset. My specific problem is in two different forms that access a &quot;PhaseList&quot; table and a &quot;PartNumber&quot; table. These two tables are related with a one to many relationship with &quot;PhaseList&quot; being the ONE side and &quot;PartNumber&quot; being the MANY side. The &quot;PartNumber&quot; table is then on the ONE side of several other tables throughout the database. I have no problem adding new records to these tables through my forms, but I get errors when I try to update or delete certain records in each table from my forms. It only occurs on some of the records in each table, but other records update fine. Another thing is that if I go directly to the linked SQL table in Access, I can make all the updates and deletes I want to the records that don't work in the form and it works fine. The specific errors that I get are: &quot;Run-time error '3157': ODBC--update on a linked table 'PhaseList' failed.&quot; or &quot;Run-time error '3156'....&quot; when I try to delete. I have tried about everything I can think of to fix the problem. I have rewrote the form’s VBA code, I have tried to update the code with a SQL statement, I have only upsized the &quot;PhaseList&quot; table and then Imported the data. That didn't work, but if I copied/pasted the data in when I only had the &quot;PhaseList&quot; table upsized, then the update PhaseList form worked. If I upsized other linked tables though it wouldn't work. I did get it to work with other upsized/linked tables if I only copied/pasted in the first 140 records from the &quot;PhaseList&quot; table. If I copied one more record in or even added my own new record to the end of the table, I would start getting the error again. I have looked into the Triggers that the upsize wizard created, but I didn't see any problems there. I am just a beginning SQL Server user, so I am not too familiar with triggers, indexes, or permissions. I have however, got the rest of my database working great, it is just these 2 forms accessing these two tables that give me a problem. I have updated these “problem” records through another form, although I was updating different fields then in the other forms. I also should note that this has never been a problem when I had an Access backend, it is only with SQL Server as the backend. Another note is that when I do get the ODBC error and I click “end” to end the procedure, if I click my “Save” button again, it runs through the same update code and works, but then if I try to update that record again, it stops working. I could really use some help! Thanks for your time.<br>
Arnold<br>

 
I had a breakthough. I got the &quot;PartNumber&quot; table to update and delete without any problems at all. When I upsized to sql server, I imported the data at the same time. When I did this, I got an error when it tried to import the data. (The error was &quot;Server Error 206: Operand type clash...&quot;) I guess Access 2000's upsizing wizard is more picky when it comes to importing data because I didn't get any problems when I imported the data from sql server. I ended up changing a memo field in Access from &quot;allow zero length&quot; No, to &quot;allow zero length&quot; yes. I also found some leading spaces in one of the fields that is part of the primary key, so I eliminated those spaces. Lastly, I added zeros to fields that had a default value of zero, but were currently null or blank.<br>
<br>
I have had problems in the past with corrupt data in Access and I think that that is the problem here. I still have not fixed the &quot;PhaseList&quot; table.<br>
<br>
Any suggestions?<br>
Thanks.<br>
Arnold
 
if there are not too many fields in the table, you might try importing only one field at a time, to help you narrow it down if it's another data problem.
 
Elizabeth,<br>
Thanks for your help.<br>
<br>
Yeah, I tried that. I cut the phaselist table down to only one field, the primary key field, and imported that. I still had the the same problems. I am currently recreating the table in sql server by hand, and then I will populate some of the records by hand and see if it will work.<br>
<br>
Arnold
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top