I have an Access front end connecting to an SQL Server back-end. When the
application opens, I run a small test to determine if the SQL Server is
available. If it is not, I have code to trap the 'On Error' event.
Unfortunately, a 'SQL Server Login' dialog appears before my 'On Error' code
has a chance to run. Does anybody know how to prevent the dialog from
appearing? Suppressing warnings (DoCmd.SetWarni ngs FALSE) has no effect.
Thanks,
Scott 5 13522
Scott A. Jones wrote: I have an Access front end connecting to an SQL Server back-end. When the application opens, I run a small test to determine if the SQL Server is available. If it is not, I have code to trap the 'On Error' event. Unfortunately, a 'SQL Server Login' dialog appears before my 'On Error' code has a chance to run. Does anybody know how to prevent the dialog from appearing? Suppressing warnings (DoCmd.SetWarni ngs FALSE) has no effect.
I have the same problem trying to open a database in DAO, no matter what
options I put into OpenDatabase() it will still prompt if the password
is wrong, etc. So I pop in a little bit of ADO...
Function CanOpenSQLDbLB( pstrServer As String, pstrDb As String, pstrUser
As String, pstrPassword As String, Optional pfReportError As Boolean =
True) As Boolean
' Error Trapped: 04/02/2003 09:50:00 Admin
On Error GoTo CanOpenSQLDbLB_ Err
' try late binding
Dim objConn As Object
Dim strConn As String
Dim strError As String, lngErr As Long
Const cstrSQLErr = "[Microsoft][ODBC SQL Server Driver][SQL Server]"
Set objConn = CreateObject("A DODB.Connection ")
strConn = strConn & "DRIVER=SQL Server"
strConn = strConn & ";SERVER=" & pstrServer
strConn = strConn & ";APP=" & Application.Nam e
strConn = strConn & ";WSID=AWorksta tion"
strConn = strConn & ";DATABASE= " & pstrDb
objConn.Open strConn, pstrUser, pstrPassword
' Q'PLAGH
CanOpenSQLDbLB = True
CanOpenSQLDbLB_ Exit:
On Error Resume Next
objConn.Close
Set objConn = Nothing
Exit Function
CanOpenSQLDbLB_ Err:
lngErr = Err.Number
strError = Err.Description
'MsgBox strError
If InStr(1, strError, cstrSQLErr) Then
strError = "Error reported by server" & vbCr & vbCr &
Replace(strErro r, cstrSQLErr, "")
End If
'Debug.Print strError
Select Case lngErr
Case Else
If pfReportError Then
MsgBox strError, 16, "Error #" & Err & " Attempting to
open server database"
End If
End Select
Resume CanOpenSQLDbLB_ Exit
End Function
--
\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\
Try linking to the SQL table with an ODBC object, and when you do, click
'Save Password'. That way you wont be prompted for the password, and you
can use the table as an access table.
HTH
Alec Christie
alec_e_christie (at)hotmail(dot )com
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
On 23-Sep-2004, Trevor Best <nospam@localho st> wrote: Function CanOpenSQLDbLB( pstrServer As String, pstrDb As String, pstrUser As String, pstrPassword As String, Optional pfReportError As Boolean = True) As Boolean ' Error Trapped: 04/02/2003 09:50:00 Admin On Error GoTo CanOpenSQLDbLB_ Err ' try late binding
Dim objConn As Object Dim strConn As String Dim strError As String, lngErr As Long Const cstrSQLErr = "[Microsoft][ODBC SQL Server Driver][SQL Server]"
Set objConn = CreateObject("A DODB.Connection ")
strConn = strConn & "DRIVER=SQL Server" strConn = strConn & ";SERVER=" & pstrServer strConn = strConn & ";APP=" & Application.Nam e strConn = strConn & ";WSID=AWorksta tion" strConn = strConn & ";DATABASE= " & pstrDb
objConn.Open strConn, pstrUser, pstrPassword
' Q'PLAGH CanOpenSQLDbLB = True
CanOpenSQLDbLB_ Exit: On Error Resume Next objConn.Close Set objConn = Nothing Exit Function CanOpenSQLDbLB_ Err: lngErr = Err.Number strError = Err.Description 'MsgBox strError If InStr(1, strError, cstrSQLErr) Then strError = "Error reported by server" & vbCr & vbCr & Replace(strErro r, cstrSQLErr, "") End If 'Debug.Print strError Select Case lngErr Case Else If pfReportError Then MsgBox strError, 16, "Error #" & Err & " Attempting to open server database" End If End Select Resume CanOpenSQLDbLB_ Exit
End Function
Trevor,
Thanks for the reply. Your code worked great! Problem solved!!
Question: What is the purpose of the pfReportError boolean? I couldn't
figure it out from reading your code.
Thanks,
Scott
Scott A. Jones wrote: On 23-Sep-2004, Trevor Best <nospam@localho st> wrote:
Function CanOpenSQLDbLB( pstrServer As String, pstrDb As String, pstrUser As String, pstrPassword As String, Optional pfReportError As Boolean = True) As Boolean ' Error Trapped: 04/02/2003 09:50:00 Admin On Error GoTo CanOpenSQLDbLB_ Err ' try late binding
Dim objConn As Object Dim strConn As String Dim strError As String, lngErr As Long Const cstrSQLErr = "[Microsoft][ODBC SQL Server Driver][SQL Server]"
Set objConn = CreateObject("A DODB.Connection ")
strConn = strConn & "DRIVER=SQL Server" strConn = strConn & ";SERVER=" & pstrServer strConn = strConn & ";APP=" & Application.Nam e strConn = strConn & ";WSID=AWorksta tion" strConn = strConn & ";DATABASE= " & pstrDb
objConn.Open strConn, pstrUser, pstrPassword
' Q'PLAGH CanOpenSQLDbLB = True
CanOpenSQLDbL B_Exit: On Error Resume Next objConn.Close Set objConn = Nothing Exit Function CanOpenSQLDbL B_Err: lngErr = Err.Number strError = Err.Description 'MsgBox strError If InStr(1, strError, cstrSQLErr) Then strError = "Error reported by server" & vbCr & vbCr & Replace(strEr ror, cstrSQLErr, "") End If 'Debug.Print strError Select Case lngErr Case Else If pfReportError Then MsgBox strError, 16, "Error #" & Err & " Attempting to open server database" End If End Select Resume CanOpenSQLDbLB_ Exit
End Function
Trevor,
Thanks for the reply. Your code worked great! Problem solved!!
Question: What is the purpose of the pfReportError boolean? I couldn't figure it out from reading your code.
Thanks, Scott
If true, a MsgBox will appear with the error message, if false then the
function quietly exits and returns 0 (IOW cannot connect).
--
\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\
Do it in reverse order: Get user name and password and then establish
connection.
Insert the ODBC connection string (with user name and password) in a SQL
sentence. This wil avoid the popup when you use the linked tables:
strOdbcCon="ODB C" _
& ";DRIVER=SQ L Server" -
& ";SERVER=YourSe rver" _
& ";DATABASE=Your Database" _
& ";uid=" & strUserName _
& ";pwd=" & strPassword
strSQL="SELECT * FROM [" & strOdbcCon & "].OneTable WHERE FALSE"
set db=currentdb
set rs=dbs.openreco rdset(strSQL,db OpenNapshot)
It works.
"Scott A. Jones" <sa*****@gmx.ne t> escribió en el mensaje
news:ci******** *@enews1.newsgu y.com... I have an Access front end connecting to an SQL Server back-end. When the application opens, I run a small test to determine if the SQL Server is available. If it is not, I have code to trap the 'On Error' event. Unfortunately, a 'SQL Server Login' dialog appears before my 'On Error'
code has a chance to run. Does anybody know how to prevent the dialog from appearing? Suppressing warnings (DoCmd.SetWarni ngs FALSE) has no effect.
Thanks, Scott This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dr. Indera |
last post by:
hi,
this may be a bit long, but i want to make sure i explain my questions. (aka, not real experienced
with visual studio.net)
i'm using visual studio.net 2003 (visual basic.net and crystal reports.net in particular).
i know that you have to have an odbc connection for the database that you will use with your
application.
|
by: DJJ |
last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL
tables to a Microsoft Access 2003 database. I am finding that the data from
the MySQL tables takes a hell of a long time to load making any kind linkage
with my Access data virtually useless.
I have the MySQL driver setup in as a USER DSN. The MySQL data is sitting
out on a server and the Access database is running locally. The network
connection is very...
|
by: Ragtimer |
last post by:
I've been trying to build a DAO.QueryDef.Connect string, building it
from a user ID and password string obtained previously by a log-in
dialog box, using it to log in to an Oracle database through an ODBC
connection. The problem I have is that it's intermittent, in that
invariably the first time I try to connect I still get the Oracle
log-in prompt where the user has to type in all the info again anyway;
and on subsequent connections...
|
by: vitagoni |
last post by:
Hi there,
I'm new in C#. But not in programming. I used to call odbc32.dll before, so
I was working with ODBC API commands.
Can you advice a way whichis better for using in VC2003 C#?
I'm trying to create an application which will automatically read DSN, read
data like table names, cols types in each table, and later build
DataSource/DataGrid objects which are adopted to the read data.
I use System.Data.Odbc namespace.
Thanks.
|
by: Jozsef Bekes |
last post by:
Hello All,
is it possible to make the ODBC connection dialog box appear when connecting to a db using the classes in the System.Data.Odbc namespace? I could not find a way except for invoking the win32 API that I would want to avoid.
Thank you for any help.
BR,
Jozsef
| |
by: Henry C. Wu |
last post by:
I tried the link: http://support.microsoft.com/?id=193128
to prompt the ODBC Data Source dialog box, but the syntax
".Properties("Prompt") = adPromptAlways" rendered an error stating
that it is only a "READONLY" property.
Any clues on how to prompt the ODBC Data source dialog box and return
the connection string after the user has selected the desired DSN?
Thanks,
Henry :)
|
by: polpe |
last post by:
Hello, i have a filemaker server 5.5 with some shared files.
I don't understand how use ODBC with these files to import a database
in
Access.
Can anyone help me?
Polpe from Italy
|
by: nark |
last post by:
I just downloaded ODBC drivers from the mySQL web site but whenever I try
to create a DSN I get a system 1157 error
The driver does show up ok in the windows control panel
I cant find any information on this at all can anyone help please?
nark
|
by: Bob Sanderson |
last post by:
I'm trying to export a table to an ODBC database using a VBA subroutine. I
have tested the ODBC setup manually and it works fine but when I try to do
it with VBA, I get a "connection failed" error. This is the code I'm using.
Can anyone tell me what is wrong with it?
DoCmd.TransferDatabase acExport, "ODBC Database",
"ODBC;DSN=*****;UID=*****;LANGUAGE=us_english;" & "DATABASE=*****",
acTable, "Test", "Test"
Thanks in advance.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |