CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Data Environment

    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

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Data Environment

    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



  3. #3
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Re: Data Environment

    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

  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Data Environment

    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


  5. #5
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Re: Data Environment

    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

  6. #6
    Join Date
    May 1999
    Posts
    3,332

    Re: Data Environment

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


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

Featured