I would like to use a Data Link file (.udl) to establish
the connection to the database so that the connection
string is not hard coded into the app. However, I am
getting confused by the fact that my connection object in
the data environment has a connection source property
instead of a connection string property. I cannot see how
to configure the connection object to read a Data Link
file.
Any ideas how I ground this?
Thanks
Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : sc...@online.microsoft.com <Remove word online. from address>
Want to know more? Check out the MSDN at msdn.microsoft.com or the Microsoft Knowledge Base at support.microsoft.com
This posting is provided “AS IS”, with no warranties, and confers no rights.
--------------------
>Content-Class: urn:content-classes:message
>From: "Ewan Walker" <walker...@stirling.gov.uk>
>Sender: "Ewan Walker" <walker...@stirling.gov.uk>
>Subject: VB6 Data Environment and ADO
>Date: Thu, 22 Aug 2002 08:29:52 -0700
>Lines: 16
>Message-ID: <cdd001c249f0$c26590d0$39ef2ecf@TKMSFTNGXA08>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Thread-Index: AcJJ8MJlhZxav7x5T5qzZRkEIuUbUw==
>Newsgroups: microsoft.public.vb.dataenvreport
>NNTP-Posting-Host: TKMSFTNGXA08 10.201.226.36
>Path: cpmsftngxa10!tkmsftngp01!cpmsftngxa06
>Xref: cpmsftngxa10 microsoft.public.vb.dataenvreport:8107
>X-Tomcat-NG: microsoft.public.vb.dataenvreport
I have tried this and when I run the app the standard
Windows Select Data Source window opens. My DE Initialize
event goes:
deMetadata.cnMetadata.ConnectionString = "FILE NAME =
c:\MyDir\Metadata.UDL"
And the content of c:\MyDir\Metadata.UDL reads:
[oledb]
'Comments
Provider=Microsoft.Jet.OLEDB.4.0;Data Source =
c:\MyDir\metadata.mdb; Persist Security Info = FALSE
I have blanked the ConnectionSource property at design
time as advised in other mails, and have tried running the
exe also - none of which works.
I will revert to using a provider string which I will
store as an environment variable if I can't get the above
to work.
Ewan
>.
>
Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : sc...@online.microsoft.com <Remove word online. from address>
Want to know more? Check out the MSDN at msdn.microsoft.com or the Microsoft Knowledge Base at support.microsoft.com
This posting is provided “AS IS”, with no warranties, and confers no rights.
--------------------
>Content-Class: urn:content-classes:message
>From: "Ewan Walker" <walker...@stirling.gov.uk>
>Sender: "Ewan Walker" <walker...@stirling.gov.uk>
>References: <cdd001c249f0$c26590d0$39ef2ecf@TKMSFTNGXA08> <XY7fTZqSCHA.3072@cpmsftngxa10>
>Subject: RE: VB6 Data Environment and ADO
>Date: Fri, 23 Aug 2002 07:50:29 -0700
>Lines: 90
>Message-ID: <69d901c24ab4$6c55db90$2ae2...@phx.gbl>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Thread-Index: AcJKtGxVH0NEC7dcQrCcHZZT4O9lFQ==
>Newsgroups: microsoft.public.vb.dataenvreport
>Path: cpmsftngxa10
>Xref: cpmsftngxa10 microsoft.public.vb.dataenvreport:8111
>NNTP-Posting-Host: TKMSFTNGXA14 10.201.226.42
>X-Tomcat-NG: microsoft.public.vb.dataenvreport
Here is my very own work around to your problem which I use often but I
dont guarante it to work in your suituation.
Just cut and paste the code below and swap my denTest with your
dataenvironment name and my connection is called cn so you need to change
this as well in the code below. A very quick way to do this is to use
notepad's replace option under the Edit menu.
Happy Programing,
Shelvin Datt.
'Cut and paste this code--------------------------------->
'first close connection down if it is open.
If denTEST.cn.State = adStateOpen Then
denTEST.cn.Close
End If
'connection for the reporting of TEST.
'If denTEST1.cn.State = adStateOpen Then
' denTEST1.cn.Close
'End If
'set connection to source in the Universal Data Link file called
TEST.UDL
'denTEST.cn.ConnectionString = "File Name=" & App.Path & "\TEST.udl;"
'denTEST.cn.Open
'denTEST.cn.Open "File Name=" & App.Path & "\TEST.udl;"
'open the udl file on our own and do the connection init
Dim sTemp As String
Open App.Path & "\TEST.udl" For Input As #1
While Not EOF(1)
Line Input #1, sTemp
'the last line in this file will be the connection string
Wend
Close #1
denTEST.cn.ConnectionString = sTemp
denTEST.cn.Open
'End of code ------------------------------->
"Ewan Walker" <walker...@stirling.gov.uk> wrote in message
news:cdd001c249f0$c26590d0$39ef2ecf@TKMSFTNGXA08...