Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Data Environment and connection string

Hi All!

I need to dynamically set the connection string of the Connection object in the data environment.  I've tried several ways, none of which worked.  Can anyone tell me where to set the string and how to set up the connection object properties in the DE so that it will take any connection string?

My attempt:

Public Function PrintCheckIn(ByVal iDrvrID As Integer, ByVal sBeginDate As String, _
                             ByVal sEndDate As String, ByVal sTitle As String)
    'Print the Check-In Report
    Dim ODE     As deAccReports
    Dim myRpt   As rptCheckIn
   
    On Error Resume Next
   
    Set ODE = New deAccReports
    Set myRpt = New rptCheckIn

    ODE.cnAccess.ConnectionString = App.Path & "\MyDatabase.mdb"
    ODE.cmCheckIn_Grouping iDrvrID, sBeginDate, sEndDate
   
    myRpt.Sections("Section4").Controls.Item(4).Caption = sBeginDate & " to " & sEndDate
    myRpt.Sections("Section2").Controls.Item(12).Caption = sTitle
   
    myRpt.Refresh
   
    If myRpt.Visible = False Then myRpt.Show

End Function

Thanks!
Alice
0
alicelknight
Asked:
alicelknight
  • 6
  • 6
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
You can set it into the "Private Sub DataEnvironment_Initialize()" event
0
 
alicelknightAuthor Commented:
emoreau:  Thanks!  Let me check it out tonight.  I didn't try that.

Alice
0
 
Éric MoreauSenior .Net ConsultantCommented:
any progress?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
alicelknightAuthor Commented:
emoreau:  No, seems not to work.  I get the .Jet Dialog box opening up for the datasource and the connectionstring, etc......  any suggestions?

Alice
0
 
Éric MoreauSenior .Net ConsultantCommented:
1. add a standard module to your project
2. in that module add a "public sub main" procedure.
3. add code to this procedure to change your connection string and open your DE.
4. from the project properties, modify the startup object to "sub main"
0
 
Éric MoreauSenior .Net ConsultantCommented:
and your connection string is not valid! where is the provider and ... all the others parameters?

see http://www.able-consulting.com/ADO_Conn.htm#OLEDBProviderForMicrosoftJet for the complete syntax.
0
 
alicelknightAuthor Commented:
emoreau:  I changed the connection string and it still doesn't work.  Nothing I do seems to change the string that's already entered in the path of the connection object in the DE.

Alice
0
 
Éric MoreauSenior .Net ConsultantCommented:
zip your project and send it to emoreau99@hotmail.com
0
 
alicelknightAuthor Commented:
emoreau:

Thanks a bunch!  It's on its way

ALice
0
 
Éric MoreauSenior .Net ConsultantCommented:
it's back to you! simply change the mdb from your connection string to MDE.
0
 
alicelknightAuthor Commented:
emoreau:  Actually, I sent the project with an .mde and not the .mdb.  My app runs with the .mdb.  But yours works! :)  The only difference I see is that you're not using the class.  And making sure the report is closed before opening.  I'm sure I can get mine to work now.  thanks a whole bunch, now my vacation will be that much nicer! :)
Alice
0
 
alicelknightAuthor Commented:
emoreau:  The problem...?  Once I put the DataEnvironment connection object and the 2 reports into the project that I am calling it from it works.  But it will not work leaving it in the ActiveX.exe.  Thanks so much for your help!

Alice
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now