Hi
I am new to SQL and I am trying to connect to mssql server via vb.net with a code someone else has done. I am not sure why it won't connect. part of the code is below:

_DBConnection = New SqlConnection '(ConnectionString)
_DBConnection.ConnectionString = "Server=MASTEC;Database=CHH_Cardboard_DA_new;User ID=sa;Password=xxxx;Trusted_Connection=False"
_DBConnection.Open()


when I run this I get the following error:

"A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error."


I am able to connect using odbcconnection but the rest of the code uses commands from System.Data.SqlClient.

Can anyone help me please. :-|

Thank you

Please cut/copy/paste your code.. so that I can say what exactly is going wrong.

Thanks

Please cut/copy/paste your code.. so that I can say what exactly is going wrong.

Thanks

Dim strDBConn As String = ""
Try
strDBConn = "Data Source=ccmsserver;Initial Catalog=db1;User ID=kamilia;Password=501011;"
Catch ex As Exception
End Try
Return strDBConn

try adding the database as a connecttion in the Server Explorer window