I have been trying to open an SQL connection using the code below I get the message shown below when the code is executed.
Based on the error message, my guess is that the problem is in the line with the Data Source information. My understanding is that the Data Source should be the Server name and location of the database. I am sure that the answer should be obvious to me, but obviously it is not.
Private Sub LogInForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim sqlString As String = "Server=localhost;" &"Data Source=SITECH88\SQLEXPRESS;Database=F:\SourceCode\Database\SQLServer\CSE_DEPT;" Try sqlConnection.Open() Catch SQLExceptionErr As SqlException MessageBox.Show(SQLExceptionErr.Message, "Access Error") Catch InvalidOperationExceptionErr As InvalidOperationException MessageBox.Show(InvalidOperationExceptionErr.Message, "Access Error") End Try If sqlConnection.State <> ConnectionState.Open Then MessageBox.Show("Database Connection Failed") Me.Close() End If End Sub
gwboolean