Results 1 to 7 of 7

Thread: [2005] how to correct the dataset connection string?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    [2005] how to correct the dataset connection string?

    My Dataset is generated by adding datasource in vb. All of my table adapter using ConnectionString1 (MySettings)
    How can I get this varible and modify its value by my coding?

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: [2005] how to correct the dataset connection string?

    Do you need to change it on the fly, or specify a different connection to your adapter? Say you have loaded ConnectionString1 for your test environment, and ConnectionString2 for your production environment, and you have setup an environment application variable. You could do something like
    Code:
    If My.Settings.Environmnet = "production" Then
        Dim ta As New MyDbTableAdapters.SomeTableAdapter
        ta.Connection.ConnectionString = My.Settings.ConnectionString2
    End If

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: [2005] how to correct the dataset connection string?

    Quote Originally Posted by wild_bill
    Do you need to change it on the fly, or specify a different connection to your adapter? Say you have loaded ConnectionString1 for your test environment, and ConnectionString2 for your production environment, and you have setup an environment application variable. You could do something like
    Code:
    If My.Settings.Environmnet = "production" Then
        Dim ta As New MyDbTableAdapters.SomeTableAdapter
        ta.Connection.ConnectionString = My.Settings.ConnectionString2
    End If
    ha, I got a question here. I find my dataset connection in mysetting:
    My.Settings.ConnectionString1

    But I find that is read only. Is that anyway to change it? Your method can be done, but I have many table adapter..

  4. #4
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: [2005] how to correct the dataset connection string?

    I'm not sure how to do this. We just switched to VS2005 a couple months ago, and all my production applications use our old 1.1 DAL architecture. I am in the same boat when we do switch to exclusivly 2.0. It has always been a pain point for us to migrate between environments. There is talk about skipping a conversion to 2.0, and going straight to 3.5, but I don't know if these issues have been addressed.

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: [2005] how to correct the dataset connection string?

    When you add a property to the My namespace, if it is of type ConnectionString, it makes it an Application Level scope setting. All Application-level settings are read only, gawd only knows why. I "get around" this by making it an ordinary string, then setting it to a User-level scope.

    that being said, everyplace where you have
    ta.Connection.ConnectionString = My.Settings.ConnectionString2

    You can replace the use of My.Settings to use a different variable with the connectionstring:
    ta.Connection.ConnectionString = mystring_with_connectionstring_init

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    PowerPoster Jenner's Avatar
    Join Date
    Jan 2008
    Location
    Mentor, OH
    Posts
    3,712

    Re: [2005] how to correct the dataset connection string?

    Quote Originally Posted by wild_bill
    I'm not sure how to do this. We just switched to VS2005 a couple months ago, and all my production applications use our old 1.1 DAL architecture. I am in the same boat when we do switch to exclusivly 2.0. It has always been a pain point for us to migrate between environments. There is talk about skipping a conversion to 2.0, and going straight to 3.5, but I don't know if these issues have been addressed.

    There's about 0 conversion between 2.0 and 3.5, so I would if I were you. The BIG difference is from 1.1 to 2.0.
    My CodeBank Submissions: TETRIS using VB.NET2010 and XNA4.0, Strong Encryption Class, Hardware ID Information Class, Generic .NET Data Provider Class, Lambda Function Example, Lat/Long to UTM Conversion Class, Audio Class using BASS.DLL

    Remember to RATE the people who helped you and mark your forum RESOLVED when you're done!

    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe. "
    - Albert Einstein

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: [2005] how to correct the dataset connection string?

    So that..If I have 20 table adapter, I need to run the code 20 times?
    Code:
    If My.Settings.Environmnet = "production" Then
        Dim ta As New MyDbTableAdapters.SomeTableAdapter1
        ta.Connection.ConnectionString = My.Settings.ConnectionString2
    End If
    Code:
    If My.Settings.Environmnet = "production" Then
        Dim ta As New MyDbTableAdapters.SomeTableAdapter2
        ta.Connection.ConnectionString = My.Settings.ConnectionString2
    End If
    That's really a hard task...

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