0

I have developed a program for a user to search a database. I did this on my local PC and it worked fine. I move the app to the server where it would used, changed the Data Source and I get an error (below). I used the name of the Server Name shown on the start up of SQL2008 R2 as the Data Source, which is the same thing I did on my local PC. I built a simple program just to test the Connection (below). I have tried different things, read everything I could find on the error, but no good.

Here is the code I'm using to test the connection:

Imports System.Data.SqlClient
Imports System.IO

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim MyConnectionString As String = " Data Source=MenClub02;Database=eCom_Email;Integrated Security=SSPI"

        Using connection As New SqlConnection(MyConnectionString)
            connection.Open()
            MsgBox("State: {0}", connection.State)
            MsgBox("ConnectionString: {0}", connection.ConnectionString)
        End Using

    End Sub
End Class

The following error shows up on the Using connection As New SqlConnection(MyConnectionString) line:

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
Source=System.Data

3
  • Have you tried all the solutions here Commented Nov 24, 2019 at 22:57
  • If something works on your machine but not on the server - this is not a code issue. this is component installation or network issue. Commented Nov 24, 2019 at 23:10
  • .NET Framework Data Provider for SQL Server Commented Nov 24, 2019 at 23:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.