none
SQL Connection String Error RRS feed

  • Question

  • I have developed a program for 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.  Any thoughts on what I might do to correct the problem? 

    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


    Carl


    Sunday, November 24, 2019 10:28 PM

Answers

  • Hello,

    Try this

    Data Source=MenClub02;Initial Catalog=eCom_Email;


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by Skip9999999999 Monday, November 25, 2019 2:11 AM
    Monday, November 25, 2019 12:15 AM
    Moderator

All replies

  • https://www.connectionstrings.com/sql-server-2008/

    Your connectionstring is not correct, look on that page 


    Success
    Cor

    Sunday, November 24, 2019 10:33 PM
  • Hello,

    Try this

    Data Source=MenClub02;Initial Catalog=eCom_Email;


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by Skip9999999999 Monday, November 25, 2019 2:11 AM
    Monday, November 25, 2019 12:15 AM
    Moderator