Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Simple change in the connection string problem... VB.net 2005

Simple change in the connection string problem... VB.net 2005

Scheduled Pinned Locked Moved Visual Basic
databasequestioncsharphardware
4 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nirishere
    wrote on last edited by
    #1

    Hi guys, I started my project on VB, stating it was a Database application. Doing that , the project was embedded to my database.mdb file, so now I could see a nice GUI of all my tables. The thing is that I need to choose the mdb in runtime, using a "File Open" dialog box. Me.ProductOrdersTableAdapter.Fill(Me.PlugDataSet.ProductOrders) Me.PORowsTableAdapter.Fill(Me.PlugDataSet.PORows) Me.PINSerialTableAdapter.Fill(Me.PlugDataSet.PINSerial) Me.CustomizationTableAdapter.Fill(Me.PlugDataSet.Customization) Me.FirmwareTableAdapter.Fill(Me.PlugDataSet.Firmware) - All these (for example) have been added to my form1.vb code. the thing is that PlugDataSet and ProductOrdersBindingSource were all generated inside the project files. All I want to do is change the DB source in runtime. How can I change the connection string for the mdb file and not affect all my code ? Thx

    M 1 Reply Last reply
    0
    • N nirishere

      Hi guys, I started my project on VB, stating it was a Database application. Doing that , the project was embedded to my database.mdb file, so now I could see a nice GUI of all my tables. The thing is that I need to choose the mdb in runtime, using a "File Open" dialog box. Me.ProductOrdersTableAdapter.Fill(Me.PlugDataSet.ProductOrders) Me.PORowsTableAdapter.Fill(Me.PlugDataSet.PORows) Me.PINSerialTableAdapter.Fill(Me.PlugDataSet.PINSerial) Me.CustomizationTableAdapter.Fill(Me.PlugDataSet.Customization) Me.FirmwareTableAdapter.Fill(Me.PlugDataSet.Firmware) - All these (for example) have been added to my form1.vb code. the thing is that PlugDataSet and ProductOrdersBindingSource were all generated inside the project files. All I want to do is change the DB source in runtime. How can I change the connection string for the mdb file and not affect all my code ? Thx

      M Offline
      M Offline
      Mandar Patankar
      wrote on last edited by
      #2

      Assuming that your dataAdapter is an OLeDB adapter. Here is what you can do. Change the connection string of dataadapter in button click event.open a fileopendialog box in the buttonclick event 'textPath is a textbox which displays the selected db path Private Sub dbConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dbConnect.Click OpenFileDialog1.ShowDialog() txtPath.Text = OpenFileDialog1.FileName Dim DBString As String DBString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source=" & txtPath.Text & ";Jet OLEDB:Engin" & _ "e Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB" & _ ":SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None" & _ ";Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLE" & _ "DB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=F" & _ "alse;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1" dataconn.ConnectionString = DBString End Sub I hope this helps Mandar Patankar Microsoft Certified professional

      N 1 Reply Last reply
      0
      • M Mandar Patankar

        Assuming that your dataAdapter is an OLeDB adapter. Here is what you can do. Change the connection string of dataadapter in button click event.open a fileopendialog box in the buttonclick event 'textPath is a textbox which displays the selected db path Private Sub dbConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dbConnect.Click OpenFileDialog1.ShowDialog() txtPath.Text = OpenFileDialog1.FileName Dim DBString As String DBString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source=" & txtPath.Text & ";Jet OLEDB:Engin" & _ "e Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB" & _ ":SFP=False;persist security info=False;Extended Properties=;Mode=Share Deny None" & _ ";Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLE" & _ "DB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=F" & _ "alse;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1" dataconn.ConnectionString = DBString End Sub I hope this helps Mandar Patankar Microsoft Certified professional

        N Offline
        N Offline
        nirishere
        wrote on last edited by
        #3

        I am not too sure about what type of connection it is. It seems like when I started the project and chose a Database project, VB.Net made a class out of the database, named it and made methods for it. I am not too familiar with VB, and all I found was XML files that define the connection strings... And all came out of simply starting a New->Project->Database I am quite lost with it, Thx

        N 1 Reply Last reply
        0
        • N nirishere

          I am not too sure about what type of connection it is. It seems like when I started the project and chose a Database project, VB.Net made a class out of the database, named it and made methods for it. I am not too familiar with VB, and all I found was XML files that define the connection strings... And all came out of simply starting a New->Project->Database I am quite lost with it, Thx

          N Offline
          N Offline
          nirishere
          wrote on last edited by
          #4

          My question is who is my dataconn which I should modify ?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups