|
-
Apr 28th, 2003, 09:49 AM
#1
Thread Starter
Lively Member
Data environments
is there any out there who can tell me how to make a data environment connection at run time?
-
Apr 28th, 2003, 01:15 PM
#2
Addicted Member
Here is how I did it in my current project:
VB Code:
Private Sub mnuNew_Click()
'Create a new ductwork file and make connection to it.
nning!
End Sub 'Preparing to setup for editing the connection source.
'print dataenvironment1.Connection1.ConnectionString
'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
'con1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
'con2="Mode=ReadWrite|Share Deny None;Persist Security Info=False"
'constring=con1 & commondialog1.filename & con2
'State is 0 if closed, 1 if open.
Dim s As Long 'State of connection : Open or closed.
Dim con1 As String, con2 As String 'Connection string fragments.
Dim constring As String 'Concatenated connection string.
con1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
con2 = ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"
s = DataEnvironment1.Connection1.State
If s Then DataEnvironment1.Connection1.Close 'Must be closed to do this trick!
CommonDialog1.Filter = "Ductwork|*.mdb"
CommonDialog1.InitDir = App.Path
CommonDialog1.Flags = cdlOFNOverwritePrompt 'Force warning of overwrite
CommonDialog1.ShowSave
DoEvents
If CommonDialog1.FileName = Empty Then Exit Sub 'No name sel. so pack in!
FileCopy App.Path & "\Source\Ducts.mdb", CommonDialog1.FileName 'Create the file!
constring = con1 & CommonDialog1.FileName & con2 'Concatenate Connection string.
DataEnvironment1.Connection1.ConnectionString = constring 'Make the substitution so it points to our new file!
DataEnvironment1.Connection1.Open 'Open for business!
HeatReader.Show 'Created a new file, so start at the begi
End Sub
-
Apr 28th, 2003, 01:21 PM
#3
Addicted Member
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:
Private Sub mnuNew_Click()
'Create a new ductwork file and make connection to it.
'Preparing to setup for editing the connection source.
'print dataenvironment1.Connection1.ConnectionString
'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
'con1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
'con2="Mode=ReadWrite|Share Deny None;Persist Security Info=False"
'constring=con1 & commondialog1.filename & con2
'State is 0 if closed, 1 if open.
Dim s As Long 'State of connection : Open or closed.
Dim con1 As String, con2 As String 'Connection string fragments.
Dim constring As String 'Concatenated connection string.
con1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
con2 = ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"
s = DataEnvironment1.Connection1.State
If s Then DataEnvironment1.Connection1.Close 'Must be closed to do this trick!
CommonDialog1.Filter = "Ductwork|*.mdb"
CommonDialog1.InitDir = App.Path
CommonDialog1.Flags = cdlOFNOverwritePrompt 'Force warning of overwrite
CommonDialog1.ShowSave
DoEvents
If CommonDialog1.FileName = Empty Then Exit Sub 'No name sel. so pack in!
FileCopy App.Path & "\Source\Ducts.mdb", CommonDialog1.FileName 'Create the file!
constring = con1 & CommonDialog1.FileName & con2 'Concatenate Connection string.
DataEnvironment1.Connection1.ConnectionString = constring 'Make the substitution so it points to our new file!
DataEnvironment1.Connection1.Open 'Open for business!
HeatReader.Show 'Created a new file, so start at the beginning.
End Sub
-
Apr 28th, 2003, 05:50 PM
#4
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|