473,756 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creating tabledef connection to login to ODBC dbase

HI, anyone know why this code doesnt work? I am trying to set up the
connect property of a tabledef so that it uses a given login and
password. however once I run it I still need to login when I open the
table

Function SetConnections( )
Dim strTableName, strSourceTableN ame As String
Dim objTableDef As TableDef
Dim strConnect As String '= "Set your connection string here"
Dim rs As Recordset
Dim li_size As Integer, ls_user As String, ls_host As String
Dim QuerydefTemp As querydef

'On Error GoTo Trapper
ls_dsn = "VAR"
ls_database = "uvarprod"
ls_user = GetLogin
ls_pwd = getPassword(CVa rDB, ls_user)
ls_uid = ls_user
strConnect = "ODBC;DSN=" & ls_dsn &
";NA=varsybhost prod.opf.swissb ank.com,9996;DB =" & _
ls_database & ";UID=" & ls_uid & ";PWD=" & ls_pwd '&
";TABLE=dbo.cur rency"

'Reset the connection property for all pass through queries
'For Each QuerydefTemp In CurrentDb.Query Defs
'If querydef.Connec t <"" Then
'querydef.Conne ct = "ODBC;" & strConnect
'End If
'Next

'Reset connections for linked tables
For Each TableDef In CurrentDb.Table Defs
If TableDef.Connec t <"" And TableDef.Name = "dbo_curren cy" Then
'Get the table name and source table name
strTableName = TableDef.Name
strSourceTableN ame = TableDef.Source TableName

'Recreate the tabledef
Set objTableDef = New TableDef
With objTableDef
..Name = strTableName & "Temp"
..SourceTableNa me = strSourceTableN ame
..Connect = strConnect
End With
CurrentDb.Table Defs.append objTableDef

'If the new tabledef was successfully created, delete the old TableDef
CurrentDb.Table Defs.Delete strTableName

'Change the name of the new tabledef to that of the old TableDef
CurrentDb.Table Defs(strTableNa me & "Temp").Nam e = strTableName

End If
Next
Set objTableDef = Nothing
Exit Function
Trapper:
MsgBox "Error setting connections to SQL Server Database"
Exit Function
End Function

Jul 21 '06 #1
0 2832

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

Similar topics

2
14635
by: TBone | last post by:
Anyone, I have a user "john" whose machine is part of the "job" domain. He is trying to establish an odbc connection to an MS SQL 2000 server on the "school" domain. He uses Windows authentication to establish the odbc connection however it gives the error "Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection." I am guessing that the odbc connection is trying to pass the credentials of job\john...
4
13498
by: Eric E | last post by:
Hi all, I'm having quite a bit of trouble with code to create linked tables in Access 2K. I create a DAO tabledef using CreateTableDef against a DAO database object, then set its connection string appropriately. The trouble is when I go to append the tableDef to the collection I get error 3264: No field defined --cannot append TableDef or Index Any suggestions?
3
6668
by: Kshitij Rajhans | last post by:
HI, How to connect to the dBase database?? One option is to create a DSN and use it.But I want to do it in some other way like just passing a connection string or like that. Thanks in advance. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
5
7355
by: Zlatko Matiæ | last post by:
Hello. In ODBC Data Source Administrator, there is a tab "Connection Pooling" and option "PerfMon" Enable/Disable. Could someone explain the meaning of the option and how it reflects to Access when having ODBC linked tables, JET queries on linked tables and pass-through queries? Thanks,
0
990
by: yefei | last post by:
it is very weird I set the same connection string for ODBC connect to dBase file in asp.net and the file is the same, just copied from one PC to another PC but what happens is that it runs well on two Desktops for the connection to get the table but when I tried to open the connection on the Labtop, the VWD closes automatically seems it have problem retrieving the data from the table
6
3801
by: Aleyna[] | last post by:
Hi all, I wanted to connect an old DBASE file (I don't know the exact version) but I could not make it at all. I couldn't find a way to execute sql statements on db file using c#. The interesting thing my old client can connect to the database and fetch data properly. I tried all possibilities that I found on the web containing using ODBC driver and importing the data into an access file and using this file instead of working on the...
0
6901
bartonc
by: bartonc | last post by:
This is a work in progress (current and active). There are some issues to resolve in supporting multiple connection types and I plan to add PySQLite to the mix. The this update is due to my suggesting the accompanying helper functions in a recent post and noticing that the ones posted here are a bit out of date. I'll post those helpers in a separate thread. I've also been working with the following database engines: MySQL 5.x SQLite3 JET...
7
3060
by: Salad | last post by:
I am converting an application from A97 to A2003. I have 2 tables created by another application as a Foxpro.dbf. The table has no index. The connect string in A97 is FoxPro 2.0;HDR=NO;IMEX=2;DATABASE=C:\Test It's really easy to connect to those tables in A97. I'm having difficulties in A2003. I'm trying to follow the instructions in http://support.microsoft.com/kb/824264/.
2
11155
by: bcbrock | last post by:
I am trying to figure out how to query some data out of a dbase IV (.dbf) file sitting on a remote server from my MySQL/PHP/Web Server. Both servers are Windows Server 2003 SP2. My MySQL/PHP/Web server is running PHP 4.3.11, MySQL 4.0.24, and IIS. I have set a system DSN on the remote machine for the directory that contains the dbase file. The DSN name is SASIxp, and the actual file I'm trying to connect to is ADST.DBF.
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9708
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.