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

Conection dataenviroment dinamyc

2 views
Skip to first unread message

Juan Euclides Reyes Carrasco

unread,
Oct 26, 2009, 3:11:01 PM10/26/09
to

As Redirect a dataenviroment at runtime

Ralph

unread,
Oct 26, 2009, 7:31:20 PM10/26/09
to

"Juan Euclides Reyes Carrasco"
<JuanEuclides...@discussions.microsoft.com> wrote in message
news:903CEC86-D0A5-49B5...@microsoft.com...

> As Redirect a dataenviroment at runtime

This is one of those things that can be done, but involves what I call a
"Fiddle-Factor" (hacks, etc), mainly because the DE was designed to be a
'design-time' design tool, with poor support for 'runtime' changes.

For one thing the DE does much of its initialization based on its initial
design-time properties before most of the average VB apps are even ready to
run.
Second, the database you redirect to must match the structure of the
original - some differences are tolerated, many are not.

The 'basic' scenario:
Say you designed DE using a Jet-formated database (.mdb) but at runtime
wanted to redirect to SQL Server. Create a 'dummy' mdb file - it only needs
the tables, fields, etc. that matches the original's structure. You don't
have to include data.
Private Sub DE_Initialize()
DE.MyConnection.ConnectionString = <"Connection String to the dummy
file">
DE.MyConnection.Open ' open it
DE.MyConnection.Close ' close it
DE.MyConnection.Provider = <"OLE DB provider for SQL Server">
DE.MyConnection.ConnectionString = <"connection string to new
datasource">
I believe that opening then closing the DE Connection closes and removes all
internal Commands, etc.

If you get "Invalid use of Property" error, or errors about "Invalid
Provider", etc. Then *Fiddle* with code location, providers, and database
structure until something works. <g> If we knew more about your particular
Problem Domain we might be more helpful, but in general it is usually a
matter of playing with the above.

Also consider using a UDL file to define the connection strings. This won't
make any real difference to the ability to redirect, but does simplify the
developement and distribution a bit.

hth
-ralph


Ralph

unread,
Oct 26, 2009, 7:39:09 PM10/26/09
to
I should also have noted, that on occasion you can just set up the new
connection within the Initialize method - all depends on how your App is
designed and doing. But usually some kind of Open/Close is need.

-ralph


Juan Euclides Reyes Carrasco

unread,
Oct 27, 2009, 9:41:01 AM10/27/09
to
Thanks Ralph, I have this configuration in the dataenviroment in my job.
datasource= c:\dir\dir1\bd.xxx. this works without problems even changing
database.
dir1, dir2, dir3 ,dir...

As I try to run in the server destination with the following path
\\servername\dir1\bd.xxx and the same database fails me "does not validate
operation in a closed component does not connect.

please excuse my English


"Ralph" wrote:

> .
>

Juan Euclides Reyes Carrasco

unread,
Oct 27, 2009, 11:01:02 AM10/27/09
to
Set DataEnvCK = Nothing
DataEnvCK.Connection1.CursorLocation = adUseClient
DataEnvCK.Connection1.ConnectionString = "Provider=Advantage.OLEDB.1;User
ID=AdsSys;Password=a2121998m220;Data Source=" & path &
"\IMMSAGENDA\IMMSDDF.ADD;Initial Catalog=MWDDF.add;Mode=ReadWrite;Advantage
Character Data Type=ADS_ANSI;Advantage Filter
Options=IGNORE_WHEN_COUNTING;Advantage Locking
Mode=ADS_PROPRIETARY_LOCKING;Advantage Security
Mode=ADS_CHECKRIGHTS;Advantage Server Type=ADS_REMOTE_SERVER;Increment User
Count=FALSE;Show Deleted Records in DBF Tables with Advantage=FALSE;Stored
Procedure Connection=FALSE;Advantage Table Type=ADS_ADT;Trim Trailing
Spaces=TRUE;Use NULL values in DBF Tables with Advantage=FALSE"
msg = MsgBox(ruta & "," & 1)
DataEnvCK.Connection1.Open
'SQL
DataEnvCK.Commands(1).CommandText = sqlfinal
'SQL
DataReportCK.Sections(4).Controls("Text8").DataField = "NAMES"
DataReportCK.Sections(4).Controls("Text7").DataField = "Estado"
DataReportCK.Sections(1).Controls("Label17").Caption = "From: " &
Format(finicial, "mm/dd/yyyy") & " To: " & Format(ffinal, "mm/dd/yyyy")
DataReportCK.Sections(1).Controls("Label18").Caption = ruta
DataEnvCK.rsCommand1_Grouping.Requery
DataReportCK.Refresh
DataReportCK.Show vbModal, Me
If DataEnvCK.rsCommand1_Grouping.State <> 0 Then
DataEnvCK.rsCommand1_Grouping.Close
If DataEnvCK.Connection1.State <> 0 Then DataEnvCK.Connection1.Close

"Ralph" wrote:

> .
>

0 new messages