• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

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