Click to See Complete Forum and Search --> : Data Environment
Dr_Michael
February 4th, 2000, 06:07 AM
How can I initialize the data environment by pressing a button, in order to connect to a different database each time?
Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece
Lothar Haensler
February 4th, 2000, 06:11 AM
since the data environment can hold many different connections, you have to code that for each connection:
place this in a command button click handler:
de.Connection1.ConnectionString = "dsn=T0010;uid=sa;pwd=xxx;database=yourdb"
de.Connection1.Open
Dr_Michael
February 4th, 2000, 06:19 AM
I have a listview with all available databases in my disk. The user selects the desired and then presses the button. In the button click event I have placed your code but it fires, saying that the data environment is already open.
Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece
Lothar Haensler
February 4th, 2000, 06:26 AM
then you have obviously already opened the connection to get the database information.
In that case you can do different things:
add a new connection to your data environment
or
close the old connection and reconnect it:
de.con.close
de.con.open newConnectionString
Dr_Michael
February 4th, 2000, 06:29 AM
I am trying to close the old connection, it works but it seems not to empty the previous data. I mean it seems to connect to the next database, but it displays the same old data.
Also, do I have to place some code to the data environment initialize event?
Michael Vlastos
Automation Engineer
Company SouthGate Hellas SA
Development Department
Athens, Greece
Lothar Haensler
February 4th, 2000, 07:22 AM
>Also, do I have to place some code to the data environment initialize event?
I haven't done that.
It would probably help, if you posted more code.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.