Can't connect to SQL 2005

B

Bob

Hello folks,

I am tring to create a connection to a SQL Server 2005 database but
cannot. I get an error messahe that

SQL Server does not exist or access denied

I have tried Windows Authentication and I have tried SQL Server
Authentication.

I have tried numerous connection strings...so I don't think it is the
connection string.

I must be missing something obvious....or something
dumb....interesting it is that I can connect using ado and Microsoft
Access.

Anybody got any ideas?

Regards,

Bob Sweeney
 
J

j1mb0jay

Bob said:
Hello folks,

I am tring to create a connection to a SQL Server 2005 database but
cannot. I get an error messahe that

SQL Server does not exist or access denied

I have tried Windows Authentication and I have tried SQL Server
Authentication.

I have tried numerous connection strings...so I don't think it is the
connection string.

I must be missing something obvious....or something
dumb....interesting it is that I can connect using ado and Microsoft
Access.

Anybody got any ideas?

Regards,

Bob Sweeney

Try something like this. Seems to work fine for me, dont forget to check the
ports in firewalled connections to allow 1433.....

public static void NewSQLConnection()
{
//Gets the location of the SQL database server.
string datasource = ApplicationSettings.MeetySettings.DNS + "\\"
+ ApplicationSettings.MeetySettings.Instance;
//Builds a connection string to connect to the database.
string connectionString = "user id=" +
ApplicationSettings.MeetySettings.Username +
"; pwd=" + ApplicationSettings.MeetySettings.Password +
"; Initial Catalog=" +
ApplicationSettings.MeetySettings.TableName +
"; Data Source=" + datasource +
";Packet Size=4096" +
";Connection Timeout=15;";

//Creates a new instanse of SqlConnection using the connection
settings above.
ApplicationSettings.MeetySettings.SQLConnection = new
SqlConnection(connectionString);
//Keep a record of the amount of data the connection is
transfering
ApplicationSettings.MeetySettings.SQLConnection.StatisticsEnabled
= true;
}
 
P

PS

Bob said:
Hello folks,

I am tring to create a connection to a SQL Server 2005 database but
cannot. I get an error messahe that

SQL Server does not exist or access denied

I have tried Windows Authentication and I have tried SQL Server
Authentication.

I have tried numerous connection strings...so I don't think it is the
connection string.

I must be missing something obvious....or something
dumb....interesting it is that I can connect using ado and Microsoft
Access.

Anybody got any ideas?

Is SqlBrowser service running?

Otherwise post some code.

PS
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Bob said:
Hello folks,

I am tring to create a connection to a SQL Server 2005 database but
cannot. I get an error messahe that

SQL Server does not exist or access denied

The error is self explanatory, check these:
1- You have the correct server name
2- You have the correct user/password
3- There is no a firewall in between the client & the server
 
N

Nik

You might also want to look at the "SQL Server 2005 Surface Area
Configuration". Looking in the tree:

- MSSQLSERVER -> Database Engine -> Remote Connections

(Where MSSQLSERVER might be a different Instance name)

You have options for "Local connections only" vs "Local and remote
connections". Your code may be trying to access SQL Server by a remote
path where ADO and Access are using a Local path.

Or something.

Nik
 

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

Top