Connection string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dim conn As New SqlConnection
Dim comm As New SqlCommand

conn.ConnectionString = "Data Source =(local);Initial
Catalog=Olympia;Integrated Security=True;"

conn.Open()
comm.Connection = conn

Is there anything wrong with the above codes? Are there any solutions to the
stated error? Because when I run the program, I receive the following error,
which points to line 4 of the above codes (conn.Open()):

"An unhandled exception of type 'System.Data.sqlClient.sqlException'
occurred in system.data.dll'. Additional Information: System error."
 
Hi Nexus,

Try with this one (from www.connectionstrings.com):
Data Source=(local);Initial Catalog=pubs;Integrated Security=SSPI;"
Or even better, drag & drop connection from Server Explorer on the form
(perhaps in a test project) and see what wizard creates for you.
 
ALWAYS add a Try/Catch block to a connection attempt. This will provide the
exception message that tells you what's REALLY going on.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top