Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27201

Connection string to MSSQL 2008 VB.NET

$
0
0
Hi Guys, I'm working on some app which have to connect to the database (MSSQL2008).
My connection string looks as follow:

Code:

#Region "[--------First of all you need database connection be set up---------]>"
    Public Function GetConnection() As OleDbConnection
        '[-------------Below is for MS SQL Server 07 / 2000 Connection String------------------]>
            Dim strConn As String = "Server=JMPANOPIO;UID=sa;PWD=123456; Database=AHD"

        Try
            Dim Conn As OleDbConnection = New OleDbConnection(strConn)

            If Conn.State <> ConnectionState.Open Then
                Conn.Open()
            End If

            Return Conn
        Catch
            Throw New Exception("The connection with the database can't be established.")
        End Try
    End Function
#End Region

Of course dosen't work [Exception Details: System.Exception: The connection with the database can't be established.]. I suppose the reason I cannot to get MSSQL is that the string is old. Anyway can You please tell me how the connection string should looks like?

Viewing all articles
Browse latest Browse all 27201

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>