954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

connecting sql to VB.NET

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

kbal024
Newbie Poster
1 post since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

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

Thanks

webchetan
Newbie Poster
1 post since May 2006
Reputation Points: 10
Solved Threads: 1
 
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

kay kay
Newbie Poster
1 post since May 2007
Reputation Points: 10
Solved Threads: 1
 

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

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You