Error: SQL Server does not exist or access denied

B

Ben

Hi

I am updating a project from Access to run on our SQL Server DB. Currently
I am struggling to connect to the database. I have this code which is
throwing this error: SQL Server does not exist or access denied.

Dim mydataadapter As New SqlDataAdapter
mydataadapter.SelectCommand = New SqlCommand(strSQL)

mydataadapter.SelectCommand.Connection = New SqlConnection("Data
Source=servername\databasename;User ID=domain\username")

mydataadapter.Fill(myDataSet, "tblClient.Client_ID")

myDataGrid.DataSource = myDataSet.Table("tblClient.Client_ID")

myDataGrid.DataBind()

Any ideas

Thanks B
 
P

Patrice

See a site such as http://www.connectionstrings.com/ for valid strings.
Basically :
Data Source is the server name, the database name goes in Initial Catalog.

AFAIK when using a Windows account, you just turn "intergrated security" on.
You can only connect using the currently used Windows account...

Patrice
 
B

Ben

Hi

I was origionally using this connection string:

mydataadapter.SelectCommand.Connection = New SqlConnection("Data
Source=server;Initial Catalog=database;Integrated Security=SSPI;")

Which throws this error - Login failed for user '(null)'. Reason: Not
associated with a trusted SQL Server connection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top