Solved

TableDefs.Append to an SQL server - wrong password

Posted on 2009-07-07
6
373 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
  • 3
  • 3
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
>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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:AviationAce
Comment Utility
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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
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
Comment Utility
You rock!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now