Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2008, 12:37 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default Resolved! --Checking for Network Connection

Hi All! Long time. Anyway, I've got an application that I want to load on each of my service techs laptop. I want them to be able to enter information while they're in the field w/o a network connection. When a connection is found, enable a button for them to refresh the field data to a linked SQL server table. I want to check for the connection each time they open the database. Make sense? Any ideas?

Thanks in advance,

Kevin

dartcoach
__________________
dartcoach
 
Old March 6th, 2008, 12:47 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can try to establish a connection to the server, and then if an error is thrown, do something, else... Like:

On Error Resume Next

Dim cn As ADODB.Connection

Set cn = New ADODB.Connection

Err.Clear

cn.Open "Provider=SQLOLEDB;Data Source=ServerName;Initial Catalog=DatabaseName;UID=UserID;PWD=Password"

If Err <> 0 Then 'error was encountered trying to connect to database
   MsgBox "something"
   Exit Sub
Else
   Me.SynchButton.Enabled = True
End If

cn.Close 'in case there was not an error. If it wasn't opened, this would throw an error, except for on error resume next, I think.

Did that help?

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 6th, 2008, 01:08 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

mmcdonal,
Thanks for the quick response! I've put your code in, but get an error with the userid being wrong. I know it's valid. Do the Servername, Databasename, userid and password require quotes?

Thanks,
Kevin

dartcoach
 
Old March 6th, 2008, 01:19 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

If you put the userid and password in plain text, they should look like this:

cn.Open "Provider=SQLOLEDB;Data Source=ServerName;Initial Catalog=DatabaseName;UID=UserID;PWD=Password"

If you put them in variables, they would look like this:

cn.Open "Provider=SQLOLEDB;Data Source=ServerName;Initial Catalog=DatabaseName;UID=" & sUser & ";PWD=" & sPassword

Normally I would not link the tables for this sort of operation, so maybe there is an issue there?

Also, the SQL Server database should be set up to use SQL Server authentication, and not Windows NT authentication.

Did any of that help?

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 6th, 2008, 01:34 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yup it helps, but our database is set up for Windows NT authentication. I agree that linking is not the best way, but it does make coding easier! I've created an ODBC connection for the db to link the tables. Any way to use that connection?

Thanks,
Kevin

dartcoach
 
Old March 6th, 2008, 02:07 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Got it! Used trusted connection - which internally will work fine.
Thanks for all your help!

Kevin

dartcoach





Similar Threads
Thread Thread Starter Forum Replies Last Post
"The remote name could not be resolved" teddyk ASP.NET 2.0 Basics 0 October 28th, 2008 12:49 AM
Connection to Network based Oracle Database soft4net ADO.NET 0 December 22nd, 2006 01:32 AM
Checking for active Internet connection jim b Classic ASP Basics 5 August 20th, 2006 01:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.