Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB6 Data Environment and ADO

190 views
Skip to first unread message

Ewan Walker

unread,
Aug 22, 2002, 11:29:52 AM8/22/02
to
I am developing a VB6 database front-end which uses a data
environment to establish various ADO objects.

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

unread,
Aug 23, 2002, 9:10:24 AM8/23/02
to
in the DataEnvironment Initialize event you should just have to set the DataEnvironment1.Connection1.ConnectionString = "File Name=Path
and Filename of UDL File"

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

Ewan Walker

unread,
Aug 23, 2002, 10:50:29 AM8/23/02
to
Thanks for the help Scot.

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

unread,
Aug 23, 2002, 1:07:59 PM8/23/02
to
That sounds pretty strange, it worked for me... You have all of your service packs installed on VB? and what version of ADO are you running
(Though that should be irrelevant in this case) Create a brand new DataProject and try it against that intead of your app to see if it works in a
simplified repro... The only thing I see different from my case is I had no spaces around the = in teh connection string (File Name=MayPath)

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

Shelvin

unread,
Aug 28, 2002, 8:14:16 PM8/28/02
to
Here you go,
there are lot of things that Microsoft will tell you that are possible with
their SDK and visual tools but there are times when you will wake up in the
morning and find out the hard way that, that is not so in your particular
suitation. But I still

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...

0 new messages