PC Review


Reply
Thread Tools Rate Thread

Adodb connection to different SQL SERVER DB

 
 
colpo@netti.fi
Guest
Posts: n/a
 
      7th May 2009
Hi,

My environment: ACCESS 2000 + SQL SERVER 2000.
I have front-end Access2000. adp and database in Sql Server.
I use Oledb adodb.connection from .adp to Sql Server.

I have only one front-end program (.adp) and there' the form and via
VBA -module user can change the connection to different Db (two
database - one for test use and the other for production for example
names TESTDB and PROD_DB - database are equally designed).

I change the connection programmaticly (to point correct database) and
almost everything goes correct in forms but in list-boxes where the
data is occupied by stored procedures, don't work the way I want. In
this case data comes from the database which are opened when I start
ACCESS -program

Is there the way to update also these stored procs to point to correct
Db ?

Or do I have to make to different .adp ?

Colpo

 
Reply With Quote
 
 
 
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      7th May 2009
First, ADP 2000 is really buggy; you should use ADP 2003 (still buggy but
much less). Maybe what you are seeing is one of those bugs. Second, how
are you proceeding to make the change and how are you reading the values for
these list boxes?

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)


<(E-Mail Removed)> wrote in message
news:355d422a-32f0-428c-99c6-(E-Mail Removed)...
> Hi,
>
> My environment: ACCESS 2000 + SQL SERVER 2000.
> I have front-end Access2000. adp and database in Sql Server.
> I use Oledb adodb.connection from .adp to Sql Server.
>
> I have only one front-end program (.adp) and there' the form and via
> VBA -module user can change the connection to different Db (two
> database - one for test use and the other for production for example
> names TESTDB and PROD_DB - database are equally designed).
>
> I change the connection programmaticly (to point correct database) and
> almost everything goes correct in forms but in list-boxes where the
> data is occupied by stored procedures, don't work the way I want. In
> this case data comes from the database which are opened when I start
> ACCESS -program
>
> Is there the way to update also these stored procs to point to correct
> Db ?
>
> Or do I have to make to different .adp ?
>
> Colpo
>



 
Reply With Quote
 
colpo@netti.fi
Guest
Posts: n/a
 
      8th May 2009
Hi,

Thanks Sylvain for your help. I don't have adp2003 but adp2007. I
would try that.
But here is my code which I use to to change connection.
I populate list box with store proc and in list box properties I have
Row Source (store proc name) and Row Source Type (Table/View/
StoredProc)

LstNames (properties)

RowSource = qryNames
RowSourceType= Table/View/StoredProc

In FrmConnect form (this form I change connection to different
database)

Private Sub Form_Open(Cancel As Integer)
Dim fOk As Boolean

' Ignore error if no active form
On Error Resume Next

Me.strServer = strServer
Me.lblDatabase.Caption = gDatabase
If strDatabase = "Test_DB;" Then
optDatabase.Value = 2
Else
optDatabase.Value = 1
End If

End Sub


Private Sub cmdOk_Click()
On Error GoTo Err_CmdOk_Click

' Here change database connection from Test--> Prod or vice versa

Dim fOk As Boolean



Select Case Me.optDatabase.Value
Case 2
strDatabase = "Test_db;"
Case Else
strDatabase = "Prod_db;"
End Select



gcnn.Close
Set gcnn = Nothing



If Not OpenConnection() Then
fOk = OpenConnection()

End If
 
Reply With Quote
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      8th May 2009
I don't see any call to Application.CurrentProject.CloseConnection and
Application.CurrentProject.OpenConnection in your code; which is what you
are supposed to do if you want to change the backend server or database
connected to.

It looks like that you are using your own connection to populate your forms.

Question: how are you populating your forms (and reports) and what do you
see in the Tables and the Queries/Views/SP windows (the tables/views/SP for
the old or the new database) after you have called your procedure to change
the connection?

--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)


<(E-Mail Removed)> wrote in message
news:afca554e-9b11-4ae9-8458-(E-Mail Removed)...
Hi,

Thanks Sylvain for your help. I don't have adp2003 but adp2007. I
would try that.
But here is my code which I use to to change connection.
I populate list box with store proc and in list box properties I have
Row Source (store proc name) and Row Source Type (Table/View/
StoredProc)

LstNames (properties)

RowSource = qryNames
RowSourceType= Table/View/StoredProc

In FrmConnect form (this form I change connection to different
database)

Private Sub Form_Open(Cancel As Integer)
Dim fOk As Boolean

' Ignore error if no active form
On Error Resume Next

Me.strServer = strServer
Me.lblDatabase.Caption = gDatabase
If strDatabase = "Test_DB;" Then
optDatabase.Value = 2
Else
optDatabase.Value = 1
End If

End Sub


Private Sub cmdOk_Click()
On Error GoTo Err_CmdOk_Click

' Here change database connection from Test--> Prod or vice versa

Dim fOk As Boolean



Select Case Me.optDatabase.Value
Case 2
strDatabase = "Test_db;"
Case Else
strDatabase = "Prod_db;"
End Select



gcnn.Close
Set gcnn = Nothing



If Not OpenConnection() Then
fOk = OpenConnection()

End If
 
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
ADODB Connection fi.or.jp.de Microsoft Excel Programming 1 10th Sep 2009 08:38 AM
ADODB Connection =?Utf-8?B?RGFpdg==?= Microsoft Access VBA Modules 3 3rd Dec 2005 10:38 PM
ADODB.Connection =?Utf-8?B?Qm9i?= Microsoft Dot NET 2 22nd Feb 2004 12:54 AM
How Do I Do This VB Code In C# - Set Conn = Server.CreateObject("ADODB.Connection") Empire City Microsoft C# .NET 2 30th Oct 2003 02:13 AM
Re: How Do I Do This VB Code In C# - Set Conn = Server.CreateObject("ADODB.Connection") Empire City Microsoft C# .NET 0 30th Oct 2003 12:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:05 AM.