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

Dale K
  • 25,246
  • 15
  • 42
  • 71
Carl
  • 29
  • 2
  • Have you tried all the solutions [here](https://stackoverflow.com/questions/6922879/exception-type-initializer-for-system-data-sqlclient-sqlconnection) – Dale K Nov 24 '19 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. – T.S. Nov 24 '19 at 23:10
  • [.NET Framework Data Provider for SQL Server](https://www.connectionstrings.com/sql-server/) – Jimi Nov 24 '19 at 23:24

0 Answers0