Fix a System.TypeInitializationException Error in SqlConnection with VB.net App

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

sql-server
vb.net
connection-string
asked on Stack Overflow Nov 24, 2019 by Carl • edited Nov 24, 2019 by Dale K

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0