[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 336
  • Last Modified:

Opening a Database from a MSDASC DataLink

The code below currently open a dialog box and allows the user to select/create a database connection.  It returns the connection string.  Once this string is returned I need it to display the data in a DataGrid in a Windows Form.  Could someone please help me out on this, thanks.

Private Sub DataSourceToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataSourceToolStripMenuItem.Click
        Dim mydlg As New MSDASC.DataLinks()
        Dim ADOcon As New ADODB.Connection()

        ADOcon = mydlg.PromptNew
        Try
            ADOcon.Open()
            If ADOcon.State = 1 Then
                'connection string returned from dialog box
                MsgBox(ADOcon.ConnectionString)
            Else
                MsgBox("Connection Failed")
            End If

        Catch ex As Exception

        End Try

    End Sub
0
dhathsato
Asked:
dhathsato
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
Is it going to be a varying set of database types that you need to connect to?

Bob
0
 
dhathsatoAuthor Commented:
If by varying database types you mean Acces, SQL, etc., then yes that is correct.  The user will be creating their user defined connection to their user defined database.  Hope this helped,
0
 
Bob LearnedCommented:
What I was really asking, though, is are you looking to access things like MySql, DB2, Informix, etc?  All those non-standard database types that need a special .NET data provider installed.

Bob
0
 
dhathsatoAuthor Commented:
nope, will be access and dbf files
0
 
Bob LearnedCommented:
If you don't have non-standard database types, then you can use the connection string to initialize an OleDbConnection.

Bob
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now