Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Connection Vb net and SQL 2005

Author  Topic 

blackice
Starting Member

1 Post

Posted - 2007-08-07 : 10:49:41
hi,
I am trying to connect Vb net with SQL Server 2005. Here is the code I use:
Dim myConnection As SqlConnection = New SqlConnection("DataSource=blackice/server;Intergated Security=SSPI;Initial Catalog=SERVER\Databases\System Databases\master")

SqlConnection is not accept as a variable. Any ideas?

Thank you

alanlambert
Starting Member

26 Posts

Posted - 2007-08-07 : 11:03:27
Make sure you have imported the appropriate namespace:

Imports System.Data.SqlClient


Also, check your query string: Data Source is two words, not one; the foward slash in the the data source name should be a back slash; you only need to put the 'server' part of the data source if you have a named instance called 'server' otherwise the machine name name will suffice (and no slash); and you should only need to have 'master' as the database name.

Alan
Go to Top of Page
   

- Advertisement -