Results 1 to 7 of 7

Thread: Here's a fun one! - Data Environments

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    148

    Exclamation

    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

  2. #2
    New Member
    Join Date
    Jul 2000
    Posts
    4
    Try this:

    Dim De as DataEnvironment1

    De.Commands("Command1").CommandText = "your query here"

    It works perfectly fine for me.
    --
    Christophe Garault

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    148
    I keep getting

    "Object variable or with not variable not set"
    Error!

    Am I missing something?

  4. #4
    New Member
    Join Date
    Jul 2000
    Posts
    4
    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

    --
    Christophe Garault

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    148
    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?

  6. #6
    New Member
    Join Date
    Jul 2000
    Posts
    4
    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!
    --
    Christophe Garault

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    148
    I got it!
    Thanx for your time!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width