Connection String Errors.

042355C

Active member
Joined
Nov 30, 2006
Messages
30
Programming Experience
Beginner
I could not get the text in strConnString into Conn. The parts in bold are what I believe the problem lies. Can someone please help me out? I am trying to connect to SQL Server, ODBC.

VB.NET:
    Public Sub functionshow(ByVal nric1 As String)
        Dim myform As New Form2
        Dim myServer As String = "AES-HP05"
        Dim myid As String = "userid"
        Dim mypassword As String = "userpassword"
        Dim myDatabase As String = "AH_HFL"
        Dim strConnString As String
        Dim participantNRIC As String
        Dim Conn As New SqlConnection
        Dim n As Integer

        Try
            strConnString = "userid=" & myid & ";password=" & mypassword & ";Database=" & myDatabase & "; Server=" & myServer & ";"
            Conn.ConnectionString = strConnString
            Conn.Open()
        Catch ex As Exception
            MsgBox("Put some sort of error trapping message in here")
        End Try

        ' Conn.ConnectionString = "///"
        If Conn.State = ConnectionState.Closed Then
            Conn.Open()
        End If
 
Last edited:
Please post in the most relevant forums. I've moved this post to the Database/Back-end > Database General Discussion area as that seems more fitting. Thanks :).
Whenever posting questions regarding databases (especially connection strings) it's a good idea to say what type of database you are using.

Not knowing the type of database and having to take a guess, I would say the problem is that 'userid' should be 'User Id' (seperated with a space). www.connectionstrings.com is a great resource for this types of problem.
 
Back
Top