Linking to MDB now failing after applying service patches?

E

Eric I

I have some linking (relink by dropping table and linking
again) that is now failing after having applied the latest
service packs and Windows 2000 sp4. I don't know for sure
that this is what has caused the problem, but it's the
only thing I can think that must have happened, since the
code has been working for years.

I rebuilt a simplified function using the northwind MDB
for demonstration. My clients are still using the other
code to relink their mdbs just fine, but since I applied
the patches, the same code fails on my machine.

I have a reference set to Microsoft DAO 3.6 set, which is
required to get this code to compile. The code also
assumes your northwind mdb file is in the default path of:

C:\Program Files\Microsoft
Office\Office\Samples\Northwind.mdb

Here's a simplified version of the code:

Public Function LinkISAMTables() As Boolean
On Error GoTo Error_Handler

Dim sTableName(7) As String
Dim i As Integer

Dim db As DAO.Database
Dim tbl As DAO.TableDef

Dim sLocalTableName As String
Dim sSourceTableName As String
Dim sConnection As String

Set db = CurrentDb

sTableName(0) = "Categories"
sTableName(1) = "Customers"
sTableName(2) = "Employees"
sTableName(3) = "Order Details"
sTableName(4) = "Orders"
sTableName(5) = "Products"
sTableName(6) = "Shippers"
sTableName(7) = "Suppliers"

For i = 0 To 7
sLocalTableName = sTableName(i)
sSourceTableName = sTableName(i)
sConnection = ";DATABASE=C:\Program
Files\Microsoft Office\Office\Samples\Northwind.mdb"

'Remove table if it already exists
If TableExists(sLocalTableName) Then
If Len(db.TableDefs(sLocalTableName).Connect)
Then 'Linked Table
db.TableDefs.Delete sLocalTableName
End If
End If

'Create Table Link
Set tbl = db.CreateTableDef(sLocalTableName,
dbAttachSavePWD, sSourceTableName, sConnection)

'note, argument dbAttachedTable doesn't work either
'On Error Resume Next

'ERROR OCCURS ON NEXT LINE
'ERROR 3001 - INVALID ARGUMENT

db.TableDefs.Append tbl
Select Case Err.Number
Case 3001 'Invalid Argument (dbAttachSavePWD?)
'Create Table Link
MsgBox "invalid argument in attach tables
script. The tables may not attach properly."
Case 3011 'Table not found in specified
database
msgbox "table not found in source db."
End Select
On Error GoTo Error_Handler
DoEvents

Next i

db.Close

Exit_Procedure:
On Error Resume Next
Set db = Nothing
Exit Function
Error_Handler:
Select Case Err.Number
Case Else
MsgBox Err.Number & ", " & Err.Description
Resume Exit_Procedure
Resume
End Select
End Function

'No problem in this next function. It's only provided
'so the function above will compile correctly.

Function TableExists(sLocalTableName As String) As Boolean
On Error GoTo Error_Handler
'Function validates the existence of a TableDef object
in the current database.
'The result determines if an object should be appended
or its Connect property refreshed.

Dim db As DAO.Database
Dim tbl As DAO.TableDef

Set db = CurrentDb

On Error Resume Next
Set tbl = db.TableDefs(sLocalTableName)
If Err.Number = 3265 Then ' Item not found.
TableExists = False
Else
TableExists = True
End If
On Error GoTo Error_Handler

Set tbl = Nothing
db.Close
Set db = Nothing

Exit_Procedure:
Exit Function
Error_Handler:
Select Case Err.Number
Case Else
MsgBox Err.Number & ", " & Err.Description
Resume Exit_Procedure
Resume
End Select
End Function


Similar code is working fine when I run it against an ODBC
data source instead of an MDB/ISAM source, which initially
lead me to believe it was the connection string that was
causing the problem. After playing with the connection
string and pulling it directly from:

?currentdb.TableDefs("categories").Connect

....which yeilded...

;DATABASE=C:\Program Files\Microsoft
Office\Office\Samples\Northwind.mdb

....I ruled out the connection as the problem.

Any insite into this issue would be appreciated.

Thanks!

Eric I
 
E

Eric Isaacs

I narrowed the problem down to q282010: Recommended Update
for Microsoft Jet 4.0 Service Pack 7 (sp7).

I figured the only thing that had changed on my Windows
2000 box was all of the service packs I had applied, but I
didn't know which one caused the problem. I ran a test on
my Windows XP box and did not receive the error with the
same MDB file that my Windows 2000 box was returning the
error on. I stepped through and applied all current
service pack to my windows xp box one at a time (rebooting
between installs) and testing the code after rebooting.
Before I installed the Jet 4.0 Service Pack 7 (sp7) (for
windows xp) the problem did not exist.

After installing and rebooting the error 3001 - "Invalid
Argument" errors started coming up. The error
specifically pops up when I run currentdb.tabledefs.append
and specify a tabledef object as the main argument. This
is what is causing my old classic code to break. I'm
going to attempt to remove sp7 from each box and see if
that resolves the problem.
 
W

Wil Davies

We may be having a similar problem, although I'm not 100% sure. After
applying Win2k SP4 (which includes JET 4 SP7) and MDAC 2.7 SP1, we began to
experience problems with a .NET application using ODBC to reach an Access
2000 db.

In our situation, the odd thing that we are trying to sort out is that the
application works without problem for anyone with administrator privileges,
so we are wondering whether it might also be related to a security patch.

(Were you also the person who mentioned,in another thread, something about
removing a semi-colon?)
 
E

Eric Isaacs

Wil,

Yes I was the one who mentioned the semi-colon but the
removing the semi-colon was bogus which I mentioned in a
following post to that thread. It didn't fix the
problem. I was stepping through the code at the time and
got past a line that I thought was causing the problem, so
assumed that removing the semi-colon worked. But then
later realized I was testing the wrong line. :blush:( That
would have been a quick fix. Sorry for the
miscommunication. I posted another post on that thread
that mentioned that I was wrong.

What you said about SP4 was very interesting. I was not
aware that it applied the Jet 4 SP7 in Win2k. I know that
the XP patch of Jet 4 sp7 caused the problem on my other
box. So that would most likely point to JET 4 SP7 again.

My ODBC stuff is still working fine. It's my JET stuff
that's broken. I have relinking code that's going to SQL
Server and relinking code that's going to other MDB
files. The SQL Server Relinking is still working. The
MDB linking has broken. I also noticed today that
QueryDefs.Append is also broken, so it goes deeper than
just linking tables.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top