PC Review


Reply
Thread Tools Rate Thread

Cant Close Connection from Access to SQL

 
 
=?Utf-8?B?TWlrZSBOYXB0aGluZQ==?=
Guest
Posts: n/a
 
      4th Apr 2006
I am trying to close the fallback SQL server connection and return to the
live one, by issuing a close followed by new open in VB script. No error is
given on close, the database connection just does not close, even when run
from a macro with no forms open. (The code works when switching databases on
the same server). Versions Access 2003 sp2, SQL Sever 2000 sp3.

Previous values: dbstr="TM", serverstr="FS2"
New values: dbstr="TM", serverstr="FS1"

ConnectionStr = "PROVIDER=SQLOLEDB.1;PERSIST SECURITY INFO=TRUE;INITIAL
CATALOG=" + dbstr + ";DATA SOURCE=" + serverstr + ";USER
ID=TimeManagerUser;PASSWORD=xxxxxxxxxx"

CurrentProject.Connection.Close --fails!
CurrentProject.Connection.Open ConnectionStr

--
--Mike Napthine RomulusEnterprises.com
 
Reply With Quote
 
 
 
 
Douglas J Steele
Guest
Posts: n/a
 
      4th Apr 2006
See whether setting it to nothing makes a difference:

CurrentProject.Connection.Close
Set CurrentProjecte.Connection = Nothing
CurrentProject.Connection.Open ConnectionStr

On the other hand, you may have to relink your tables instead.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Mike Napthine" <(E-Mail Removed)> wrote in message
news:46FBF083-8896-4115-8A0A-(E-Mail Removed)...
> I am trying to close the fallback SQL server connection and return to the
> live one, by issuing a close followed by new open in VB script. No error

is
> given on close, the database connection just does not close, even when run
> from a macro with no forms open. (The code works when switching databases

on
> the same server). Versions Access 2003 sp2, SQL Sever 2000 sp3.
>
> Previous values: dbstr="TM", serverstr="FS2"
> New values: dbstr="TM", serverstr="FS1"
>
> ConnectionStr = "PROVIDER=SQLOLEDB.1;PERSIST SECURITY INFO=TRUE;INITIAL
> CATALOG=" + dbstr + ";DATA SOURCE=" + serverstr + ";USER
> ID=TimeManagerUser;PASSWORD=xxxxxxxxxx"
>
> CurrentProject.Connection.Close --fails!
> CurrentProject.Connection.Open ConnectionStr
>
> --
> --Mike Napthine RomulusEnterprises.com



 
Reply With Quote
 
=?Utf-8?B?TWlrZSBOYXB0aGluZQ==?=
Guest
Posts: n/a
 
      4th Apr 2006
Good idea, but that gave me an error "invalid use of property", probably as
that is the main access connection, I fear I may have to make a new copy as
suggested, thanks.
--
--Mike Napthine RomulusEnterprises.com


"Douglas J Steele" wrote:

> See whether setting it to nothing makes a difference:
>
> CurrentProject.Connection.Close
> Set CurrentProjecte.Connection = Nothing
> CurrentProject.Connection.Open ConnectionStr
>
> On the other hand, you may have to relink your tables instead.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Mike Napthine" <(E-Mail Removed)> wrote in message
> news:46FBF083-8896-4115-8A0A-(E-Mail Removed)...
> > I am trying to close the fallback SQL server connection and return to the
> > live one, by issuing a close followed by new open in VB script. No error

> is
> > given on close, the database connection just does not close, even when run
> > from a macro with no forms open. (The code works when switching databases

> on
> > the same server). Versions Access 2003 sp2, SQL Sever 2000 sp3.
> >
> > Previous values: dbstr="TM", serverstr="FS2"
> > New values: dbstr="TM", serverstr="FS1"
> >
> > ConnectionStr = "PROVIDER=SQLOLEDB.1;PERSIST SECURITY INFO=TRUE;INITIAL
> > CATALOG=" + dbstr + ";DATA SOURCE=" + serverstr + ";USER
> > ID=TimeManagerUser;PASSWORD=xxxxxxxxxx"
> >
> > CurrentProject.Connection.Close --fails!
> > CurrentProject.Connection.Open ConnectionStr
> >
> > --
> > --Mike Napthine RomulusEnterprises.com

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CLOSE and OPEN New SQL Connection in Access? Al Franz Microsoft Access ADP SQL Server 1 11th Oct 2007 03:35 PM
how do I close the connection from excel to access after refresh? =?Utf-8?B?U3RldmU=?= Microsoft Excel Programming 0 10th Oct 2007 04:41 PM
Explicitly close DataReader if I close the underlying connection?" MarkusJNZ@gmail.com Microsoft Dot NET Framework 2 1st Nov 2006 05:49 AM
Close ODBC Connection / DSN vs DSN-less Connection / Access 2k2 Front-End Greg Strong Microsoft Access 8 10th Jul 2006 06:32 AM
Singleton Pattern for Database Access --- Leave Open or Close Connection mescano Microsoft VB .NET 4 13th Apr 2005 03:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:02 PM.