We help IT Professionals succeed at work.
Get Started

Cannot load Interop.MSDASC in VB.net app

2,105 Views
Last Modified: 2013-11-26
I'm trying to add the Data Link Properties window to my app to allow my users to quickly build a connection string to a database (Access, SQL, etc.) without having to know all the data providers for each.  I was following directions found here: http://www.codeguru.com/vb/gen/vb_database/article.php/c5139.  After adding references to my project for ADODB and Microsoft OLE DB Service Component 1.0 Type Library I used the code below to load the Datalink properies form when I click a button.  However, when I try to do the click the button, Visual Studio returns the following error:

"Could not load file or assembly 'Interop.MSDASC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."

What am I doing wrong.
Imports MSDASC
Imports ADODB

Public Class Form1
	Inherits System.Windows.Forms.Form

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		If Not My.Settings.ConnString Is Nothing Then
			txtConnString.Text = My.Settings.ConnString.ConnectionString
		End If
	End Sub

	Private Sub btnConnString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnString.Click
		Dim myDataLinkProp As DataLinksClass = New DataLinksClass
		Dim myConnection As ConnectionClass = New ConnectionClass

		If myDataLinkProp.PromptEdit(myConnection) Then txtConnString.Text = myConnection.ConnectionString

	End Sub

	Private Sub SaveConnectionStringToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveConnectionStringToolStripMenuItem.Click
		My.Settings.ConnString.ConnectionString = txtConnString.Text
	End Sub
End Class

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE