Click to See Complete Forum and Search --> : Here's a fun one! - Data Environments
hyme
Jul 28th, 2000, 08:39 AM
Howdy!
I can set up the Data connection through the data environment no problem, but is it possible to change the SQL statement through code for the Data Environment while the program is running?.
For example:
DE.dcn1.command1.commandtext = "Select * from Table1"
This doesn't work, If anyone has any ideas, it'll help.
Thanx
Toff
Jul 28th, 2000, 09:16 AM
Try this:
Dim De as DataEnvironment1
De.Commands("Command1").CommandText = "your query here"
It works perfectly fine for me.
hyme
Jul 28th, 2000, 09:23 AM
I keep getting
"Object variable or with not variable not set"
Error!
Am I missing something?
Toff
Jul 28th, 2000, 09:29 AM
You should create an instance of your data environment first:
set De = new DataEnvironment1
and then establish the connections:
Dim i as integer
for i = 1 to De.Connections.Count
'Here u can also update properties like the data source, the user Id and the password:
'De.Connections(i).Properties("Data Source")= BckpServer
'De.Connections(i).Properties("Connect Timeout")=ConnectTimeout
'De.Connections(i).Properties("User ID")=UserName
'De.Connections(i).Properties("Password")=Password
'De.Connections(i).Open
next i
hyme
Jul 28th, 2000, 09:34 AM
Now I'm getting
Class does not support Automation or does not support
expected interface
Set De = New DataEnvironment
It won't allow me to use this
Set De = New DataEnvironment1 - "User type not defined
Could I be missing a reference?
Toff
Jul 28th, 2000, 10:02 AM
Use the name of your data environment class instead of
DataEnvironment1. In the french version of VB the default values are DataEnvironment1 and Connection1.
Change them to reflect the one you've created.
In your first message you had this line of code:
DE.dcn1.command1.commandtext = "Select * from Table1"
so juste change it by
DE.Commands.("command1").CommandText = "Select * from Table1"
If this doesn't work (after instanciation of your data environment of course) I can't do more. But be sure that it works fine!
hyme
Jul 28th, 2000, 10:04 AM
I got it!
Thanx for your time!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.