Results 1 to 4 of 4

Thread: Data environments

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70

    Data environments

    is there any out there who can tell me how to make a data environment connection at run time?

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    Michigan
    Posts
    181
    Here is how I did it in my current project:
    VB Code:
    1. Private Sub mnuNew_Click()
    2. 'Create a new ductwork file and make connection to it.
    3.  
    4. nning!
    5. End Sub 'Preparing to setup for editing the connection source.
    6. 'print dataenvironment1.Connection1.ConnectionString
    7. 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Ducts.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False
    8. 'con1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
    9. 'con2="Mode=ReadWrite|Share Deny None;Persist Security Info=False"
    10. 'constring=con1 & commondialog1.filename & con2
    11. 'State is 0 if closed, 1 if open.
    12. Dim s As Long   'State of connection : Open or closed.
    13. Dim con1 As String, con2 As String  'Connection string fragments.
    14. Dim constring As String 'Concatenated connection string.
    15. con1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
    16. con2 = ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"
    17. s = DataEnvironment1.Connection1.State
    18. If s Then DataEnvironment1.Connection1.Close    'Must be closed to do this trick!
    19. CommonDialog1.Filter = "Ductwork|*.mdb"
    20. CommonDialog1.InitDir = App.Path
    21. CommonDialog1.Flags = cdlOFNOverwritePrompt 'Force warning of overwrite
    22. CommonDialog1.ShowSave
    23. DoEvents
    24. If CommonDialog1.FileName = Empty Then Exit Sub 'No name sel. so pack in!
    25. FileCopy App.Path & "\Source\Ducts.mdb", CommonDialog1.FileName 'Create the file!
    26. constring = con1 & CommonDialog1.FileName & con2 'Concatenate Connection string.
    27. DataEnvironment1.Connection1.ConnectionString = constring   'Make the substitution so it points to our new file!
    28. DataEnvironment1.Connection1.Open   'Open for business!
    29. HeatReader.Show     'Created a new file, so start at the begi
    30. End Sub

  3. #3
    Addicted Member
    Join Date
    Aug 2002
    Location
    Michigan
    Posts
    181
    The idiot mouse got into moving instead of copying. I thought I had it fixed.
    Repost to correct error:

    Here is how I did it in my current project:
    VB Code:
    1. Private Sub mnuNew_Click()
    2. 'Create a new ductwork file and make connection to it.
    3.  'Preparing to setup for editing the connection source.
    4. 'print dataenvironment1.Connection1.ConnectionString
    5. 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\Ducts.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False
    6. 'con1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
    7. 'con2="Mode=ReadWrite|Share Deny None;Persist Security Info=False"
    8. 'constring=con1 & commondialog1.filename & con2
    9. 'State is 0 if closed, 1 if open.
    10. Dim s As Long   'State of connection : Open or closed.
    11. Dim con1 As String, con2 As String  'Connection string fragments.
    12. Dim constring As String 'Concatenated connection string.
    13. con1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
    14. con2 = ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"
    15. s = DataEnvironment1.Connection1.State
    16. If s Then DataEnvironment1.Connection1.Close    'Must be closed to do this trick!
    17. CommonDialog1.Filter = "Ductwork|*.mdb"
    18. CommonDialog1.InitDir = App.Path
    19. CommonDialog1.Flags = cdlOFNOverwritePrompt 'Force warning of overwrite
    20. CommonDialog1.ShowSave
    21. DoEvents
    22. If CommonDialog1.FileName = Empty Then Exit Sub 'No name sel. so pack in!
    23. FileCopy App.Path & "\Source\Ducts.mdb", CommonDialog1.FileName 'Create the file!
    24. constring = con1 & CommonDialog1.FileName & con2 'Concatenate Connection string.
    25. DataEnvironment1.Connection1.ConnectionString = constring   'Make the substitution so it points to our new file!
    26. DataEnvironment1.Connection1.Open   'Open for business!
    27. HeatReader.Show     'Created a new file, so start at the beginning.
    28. End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    70
    Thanks I'll give it a try!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width