Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Mar 2005
    Location
    Salem, Oregon, USA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Update database (VB.Net)

    Is there a way to modify the connection string with a variable when you use table adapters? I have an app that will update an access database using table adapters, but I want the user to be able to navigate to the database (set the path). Can you do this with table adapters, or do you need to code it all in.

    Thanks, Chris

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update database (VB.Net)

    Do you mean a Data Adapter (like OleDbDataAdapter or SqlDataAdapter)? If so, you'll also need a Connection (OleDbConnection, SqlConnection, etc.).

    In which case, you can dynamically set the Connection's ConnectionString property, which can easily be built by inserting the desired database path.

  3. #3
    New Lounger
    Join Date
    Mar 2005
    Location
    Salem, Oregon, USA
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update database (VB.Net)

    Mark,

    I am new to .net, and don't really understand which procedures work the best. I used this code:

    Private Sub FrmFirsDeployment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Try
    Me.Validate()
    Me.LayersTableAdapter.UpdateQueryFires()
    Me.LayersTableAdapter.InsertQueryORID()
    Me.LayersTableAdapter.UpdateQueryMagneticDec()
    Me.LayersTableAdapter.UpdateQueryOwn()
    Me.IdentifyReportLayersTableAdapter.UpdateIDrep(Me .FirsControlDBDataSet.IdentifyReportLayers)
    MsgBox("Update successful")
    Me.Close()

    Catch ex As Exception
    MsgBox("Update failed")
    End Try
    End Sub

    which worked fine. I made the queries within the dataset.xsd. Where do I dynamically set the connection string properties?

    Thanks, Chris

  4. #4
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Update database (VB.Net)

    I sounds like you've used the graphical objects to build out your database connection (XSD file and Table Adapters), as opposed to the code-based options I mentioned in my last post.

    If you're using VB 2005, the connection string should automatically be placed under the My Settings group (My.MySettings.Default.<YourObject>ConnectionStrin g).

    If you're using VB 2003, you'll need to employ a Connection object (OleDbConnection) on the actual form. You can change the ConnectionString property of that object.

    I haven't used VB for quite some time (although I use C# on a daily basis), so my suggestions may be slightly off.

    Hope this helps...

Posting Permissions

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