Brett Barabash
BBarabash at TappeConstruction.com
Mon Sep 20 09:59:48 CDT 2004
>First, I think this is for attached Jet databases only. No, I have used this extensively for attaching to our SQL Server 2000 databases. >Second, I guess this should be: >tdAttach.Attributes = tdAttach.Attributes Or dbAttachSavePWD Good point. >Also, this should not be necessary: <snip> A couple of points here: 1. The TableDef object doesn't have a Refresh method. Perhaps RefreshLink? 2. If you try this, omit the tdf.SourceTableName = rs!ForeignName line. It blows up. 3. I can't remember the exact reason why I dropped and recreated the table. I can recall trying the simple update and RefreshLink but had difficulties. Can't remember much more than that. Seems to work OK now, though. -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Sunday, September 19, 2004 9:56 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Connecting to SQL from Access w/a single login? Hi Brett > Try setting tdAttach.Attributes = dbAttachSavePWD First, I think this is for attached Jet databases only. Second, I guess this should be: tdAttach.Attributes = tdAttach.Attributes Or dbAttachSavePWD or you would kill any other attribute (or raise an error). Also, this should not be necessary: > Do Until rs.EOF > Debug.Print rs!Name > Set tdf = db.CreateTableDef(rs!Name) > > tdf.Connect = "ODBC;" & _ > ExtractArg(rs!Connect, "DRIVER") & ";" & _ > "SERVER=" & strServer & ";" & _ > ExtractArg(rs!Connect, "DATABASE") & ";" & _ > "UID=" & strUID & ";" & _ > "PWD=" & strPWD > > tdf.Attributes = dbAttachSavePWD > tdf.SourceTableName = rs!ForeignName > db.TableDefs.Delete rs!Name > db.TableDefs.Append tdf > > rs.MoveNext > Loop A Refresh is normally fine (and faster): Set tdf = db.TableDefs(rs!Name) tdf.Connect = "ODBC;" & _ ... tdf.Attributes = dbAttachSavePWD tdf.SourceTableName = rs!ForeignName tdf.Refresh /gustav > I'm using a similar routine currently. I have a metadata table full > of information about the data tables. It contains the localname, path > and sourceobject name of the table I'm linking to in SQL Server. > The actual linking is fine, but as you said remembering the password > is an issue. -- -------------------------------------------------------------------------------------------------------------------- The information in this email may contain confidential information that is legally privileged. The information is only for the use of the intended recipient(s) named above. If you are not the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or the taking of any action in regard to the content of this email is strictly prohibited. If transmission is incorrect, unclear, or incomplete, please notify the sender immediately. The authorized recipient(s) of this information is/are prohibited from disclosing this information to any other party and is/are required to destroy the information after its stated need has been fulfilled. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Tappe Construction Co. This footer also confirms that this email message has been scanned for the presence of computer viruses.Scanning of this message and addition of this footer is performed by SurfControl E-mail Filter software in conjunction with virus detection software.