Link to home
Start Free TrialLog in
Avatar of dhathsato
dhathsatoFlag for United States of America

asked on

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
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Is it going to be a varying set of database types that you need to connect to?

Bob
Avatar of dhathsato

ASKER

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,
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
nope, will be access and dbf files
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial