Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2003
    Posts
    9

    Unhappy Unanswered: Help needed on DataEnvironment Design

    I have a question about Data Environment that I used in a VB utility. Usually when I make a connection object, I set connection string through the property dialog interface in the design time. Now I want to set the connection string dynamically in the run time, for example, the utility can be run both in my local and server, how to do that?


    Thanks in advance!

  2. #2
    Join Date
    Feb 2003
    Location
    Montreal, Canada
    Posts
    117

    Re: Help needed on DataEnvironment Design

    Public Sub DataEnvironment_Initialize()
    If Connection1.State = adStateOpen Then Connection1.Close
    Connection1.Properties("Data Source").Value = your_server_name
    Connection1.Properties("Initial Catalog").Value = your_database_name
    Connection1.Properties("User ID").Value = user_name
    Connection1.Properties("Password").Value = password
    Connection1.Open
    End Sub

    where Connection1 is your connection.

    Originally posted by heidil90
    I have a question about Data Environment that I used in a VB utility. Usually when I make a connection object, I set connection string through the property dialog interface in the design time. Now I want to set the connection string dynamically in the run time, for example, the utility can be run both in my local and server, how to do that?


    Thanks in advance!
    Steve

  3. #3
    Join Date
    Mar 2003
    Posts
    9

    Re: Help needed on DataEnvironment Design

    Thank you, Steve!

    When I debug the code, it runs fine in the initilization of data environment, however, it stuck in the frmMain form_load.

    I made command object named Course. I retrieved the titles into a datacombo box from Course Table in the database by using recordeset.

    ctlCourse.text=deWS.rsCourse!Title


    The system complains that Invalid object name 'Module'.

    Before I tried to set different connection, it runs fine in this line.

    Do you have any idea about this problem? Thanks a lot!

    Heidi

  4. #4
    Join Date
    Mar 2003
    Posts
    9

    Re: Help needed on DataEnvironment Design

    ))) Thanks a ton, Steve!

    I figured out why it complains about invalid object name. Now it runs fine!


    Have a nice, nice spring day!

    Heidi

  5. #5
    Join Date
    Feb 2003
    Location
    Montreal, Canada
    Posts
    117

    Re: Help needed on DataEnvironment Design

    Do you have some functions defined in a module?
    Does your recordset is supposed to be open before entering into DataEnvironment_Initialize Sub. In this case the recordset will lose the connection, meaning that you'll need to re-open it. I suggest to open your recorset once the connection established (Initialize Sub), and use DataSource and DataMember properties of the combo to link the data.

    Could you post your code here?


    Originally posted by heidil90
    Thank you, Steve!

    When I debug the code, it runs fine in the initilization of data environment, however, it stuck in the frmMain form_load.

    I made command object named Course. I retrieved the titles into a datacombo box from Course Table in the database by using recordeset.

    ctlCourse.text=deWS.rsCourse!Title


    The system complains that Invalid object name 'Module'.

    Before I tried to set different connection, it runs fine in this line.

    Do you have any idea about this problem? Thanks a lot!

    Heidi
    Steve

Posting Permissions

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