Solved

TableDefs.Append to an SQL server - wrong password

Posted on 2009-07-07
6
380 Views
Last Modified: 2013-11-27
I have an MS Access front end to an SQL Server back end.  Everything is working fine except for the way a bad password is handled.

Where a bad password is part of the connection string I get an error message box and then a dialog box that would have me input the correct credentials for the SQL server.  I would like to trap this so I can have my own custom error messge.

Any ideas?
Dim db As DAO.Database
Dim tdf As DAO.TableDef
. 
.
.
db.TableDefs.Append tdf '<---- error here with bad password

Open in new window

0
Comment
Question by:AviationAce
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24797803
this should do:

Sub ...
Dim db As DAO.Database
Dim tdf As DAO.TableDef
. 
.
.
on error goto ErrHandleAppendFailure
db.TableDefs.Append tdf '<---- error here with bad password
... 
Exit Sub 
ErrHandleAppendFailure:
. ..  handle the  error here... 
Exit Sub
End Sub

Open in new window

0
 

Author Comment

by:AviationAce
ID: 24797919
I tried your suggestion.  I didn't work.  I still get the SQL error message and the dialog box asking for credientials.  I think (I'm not sure) that the error message is coming from the ODBC driver.  What do you think?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24797965
>I think (I'm not sure) that the error message is coming from the ODBC driver.  What do you think?
possibly. you are using DSN entry for the linked table?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:AviationAce
ID: 24798011
I'm not using a DSN file.  I make a connection string.  When I the variable strPWD has a bad password for the SQL server: I get the error message and dialog box asking for SQL credientials.
Dim sConn As String
sConn = "ODBC;Description=MySQL Tables;DRIVER=SQL Server;" & _
        "SERVER=" & strServerName & ";APP=2007 Microsoft Office system;" & _
        "DATABASE=MyDB;" & _
        "UID=" & strUserName & ";PWD=" & strPWD & _
        ";Network=MyNet;TABLE=" & strTableName
Debug.Print sConn
tdf.Connect = sConn

Open in new window

0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24798458
ok.
you might try to connect first (without the table=xxx) part:
dim cnn as adodb.connection
set cnn = new adodb.connection
on error goto ErrHandleConnectionProblem
cnn.open sConn 
cnn.close
set cnn = nothing
 
...
 
 
ErrHandleConnectionProblem:
  ....

Open in new window

0
 

Author Closing Comment

by:AviationAce
ID: 31600786
You rock!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question