473,385 Members | 1,615 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,385 software developers and data experts.

Switching between multiple dsn-less connections

I have taken several individual apps that each use a dsn and combined
them into one app. I was wondering if anyone has any sample code that
would allow switching between odbc dsn-less connections to multile
dbs, with and without Trusted NT? the following function works but I
can't figure out the logic to deploy it. Essentially the databases and
tables would change based on what form is opened. Currently the
approach I've used is create a table--> create a form-->create a dsn
connection-->create an autoexec function that sets the dsn up on the
users machine.

I have successfully deployed an app using the following dsn-less
connection and I like this approach but I'm thinking some kind of "IIF
this form is opened from my switchboard then use this
connection-->when this form closes close this connection" approach
might work. I do have a couple of forms that would use the same
connection as well. I'm open to any suggestions.

Function LinkTableDSNLess()
'Deletes a table and relinks it if it exists and links a table if it
doesnt exist
On Error Resume Next
DoCmd.DeleteObject acTable, "dbo_<mytablename>"
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim sConnect As String

sConnect = "ODBC;DRIVER={SQL Server};" & _
"SERVER=<myserver>;" & _
"DATABASE=<mydatabase>;" & _
"UID=<myuid>;" & _
"PWD=<mypwed>tprdrbc;" & ";"

Set db = CurrentDb()
Set tdf = db.CreateTableDef("dbo_<mytablename>")
tdf.SourceTableName = "dbo.<mytablename>"

tdf.Connect = sConnect

db.TableDefs.Append tdf
db.TableDefs.Refresh

Set tdf = Nothing
Set db = Nothing

End Function

FYI, I only use SQL Server databases and ODBC but I'm open to other
methods if I can have some hand holding.

I would appreciate any assistance anyone could provide.

Paul
Nov 12 '05 #1
2 2422
rkc

"Paul Mitchell" <pa**@marysvillenow.com> wrote in message
news:d5**************************@posting.google.c om...
I have taken several individual apps that each use a dsn and combined
them into one app. I was wondering if anyone has any sample code that
would allow switching between odbc dsn-less connections to multile
dbs, with and without Trusted NT? the following function works but I
can't figure out the logic to deploy it. Essentially the databases and
tables would change based on what form is opened. Currently the
approach I've used is create a table--> create a form-->create a dsn
connection-->create an autoexec function that sets the dsn up on the
users machine.

I have successfully deployed an app using the following dsn-less
connection and I like this approach but I'm thinking some kind of "IIF
this form is opened from my switchboard then use this
connection-->when this form closes close this connection" approach
might work. I do have a couple of forms that would use the same
connection as well. I'm open to any suggestions.

Function LinkTableDSNLess()
'Deletes a table and relinks it if it exists and links a table if it
doesnt exist
On Error Resume Next
DoCmd.DeleteObject acTable, "dbo_<mytablename>"
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim sConnect As String

sConnect = "ODBC;DRIVER={SQL Server};" & _
"SERVER=<myserver>;" & _
"DATABASE=<mydatabase>;" & _
"UID=<myuid>;" & _
"PWD=<mypwed>tprdrbc;" & ";"

Set db = CurrentDb()
Set tdf = db.CreateTableDef("dbo_<mytablename>")
tdf.SourceTableName = "dbo.<mytablename>"

tdf.Connect = sConnect

db.TableDefs.Append tdf
db.TableDefs.Refresh

Set tdf = Nothing
Set db = Nothing

End Function

FYI, I only use SQL Server databases and ODBC but I'm open to other
methods if I can have some hand holding.


What version of Access?
Have you considered binding the forms to an ADODB recordset instead of
deleting and creating links?


Nov 12 '05 #2
"rkc" <rk*@yabba.dabba.do.rochester.rr.bomb> wrote in message news:<_b*****************@twister.nyroc.rr.com>...
"Paul Mitchell" <pa**@marysvillenow.com> wrote in message
news:d5**************************@posting.google.c om...
I have taken several individual apps that each use a dsn and combined
them into one app. I was wondering if anyone has any sample code that
would allow switching between odbc dsn-less connections to multile
dbs, with and without Trusted NT? the following function works but I
can't figure out the logic to deploy it. Essentially the databases and
tables would change based on what form is opened. Currently the
approach I've used is create a table--> create a form-->create a dsn
connection-->create an autoexec function that sets the dsn up on the
users machine.

I have successfully deployed an app using the following dsn-less
connection and I like this approach but I'm thinking some kind of "IIF
this form is opened from my switchboard then use this
connection-->when this form closes close this connection" approach
might work. I do have a couple of forms that would use the same
connection as well. I'm open to any suggestions.

Function LinkTableDSNLess()
'Deletes a table and relinks it if it exists and links a table if it
doesnt exist
On Error Resume Next
DoCmd.DeleteObject acTable, "dbo_<mytablename>"
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim sConnect As String

sConnect = "ODBC;DRIVER={SQL Server};" & _
"SERVER=<myserver>;" & _
"DATABASE=<mydatabase>;" & _
"UID=<myuid>;" & _
"PWD=<mypwed>tprdrbc;" & ";"

Set db = CurrentDb()
Set tdf = db.CreateTableDef("dbo_<mytablename>")
tdf.SourceTableName = "dbo.<mytablename>"

tdf.Connect = sConnect

db.TableDefs.Append tdf
db.TableDefs.Refresh

Set tdf = Nothing
Set db = Nothing

End Function

FYI, I only use SQL Server databases and ODBC but I'm open to other
methods if I can have some hand holding.


What version of Access?
Have you considered binding the forms to an ADODB recordset instead of
deleting and creating links?


I'm using Access 2000. I'm basically using ODBC because it's already
being used in the individual front ends and I know they currently
work. Additionally, Secondly these tools will probably only be around
for another 30 days or so. Last and the biggest reason: I don't
understand ADODB at all. I could probably get by with some type of
tabledef refresh but I think the datasets on the back end will change
a couple of times so it'll have to be a delete relink, refresh set-up.
Thanks for your response by the way...got me thinking about some other
things.
Nov 12 '05 #3

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

Similar topics

0
by: Leader | last post by:
HI All, I created a SQL Server DSN using Windows ODBC Data Source Administrator. While creating the DSN, it asked me about authentication process in reply to which I selected "With SQL Server...
2
by: David | last post by:
Hi, I have an MS Access database in which the tables have been exported to a MySQL DB on a Cobalt Qube 3 server and then import linked back into MS Access. This was all done via an User DSN...
4
by: Steve Sweales | last post by:
I'm trying to find some code on how to create a DSN using C# and SQLConfigDataSource. Can anybody help me please, before I tear my hair out!! *** Sent via Devdex http://www.devdex.com ***...
2
by: Johann Blake | last post by:
The following is a bug I have discovered using tab pages and threads and I am looking for a workaround. Create a new Windows Forms application and add a tab control with two tab pages. Add a...
9
by: Mike | last post by:
In my code i'm pointing to a SQL server name and SQL database name on the server, etc. Instead of that how can i point to a DSN connection on the web server that points to the SQL Server and DB?
1
by: walt | last post by:
A few years ago I wrote an active-X server to maintain a single connection to a file .mdb from multiple apps on same PC because I was having to many database curptions. Should I use the same...
0
by: Neo | last post by:
Hello All, ODBCAD32.exe launches DSN Setup. But then I have to select DSN and click configure to configure DSN. Is there any way, I could invoke configuration dialog box for particular DSN...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
9
by: LVP | last post by:
Hello, What are the ways to switch from http to https. Is there a way internal to IIS 6.0 or x.xx? Some configuration? Is there a way via DNS? I have seen Scripts in VB and JavaScript ...
6
by: Al Moodie | last post by:
Hi, I have a MySQL database where I want to updated multiple records. The table has two columns: product_number product_price I have a list with first entry product_price, second entry...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.