PDA

Click to See Complete Forum and Search --> : SQL server does not exist or access denied


steve_rm
Apr 30th, 2003, 04:24 AM
Hello

I have set up a SQL database and a ASP.Net application.
When l click on a button to fill a datagrid with data from a table
in the database i get this error message when l try to open the
database connection. This is my code


'Setup our core objects, mainly for use with our database
Dim objConnection As New SqlClient.SqlConnection("server=.;database=keepFit;trusted_connection=true")
Dim objCommand As New SqlClient.SqlCommand("Select * from Members", objConnection)
Dim objReader As SqlClient.SqlDataReader

'Open our database connection
objConnection.Open() //Error - SQL server does not exist or access denied


Many thanks in advance

Steve

afterMoon
Apr 30th, 2003, 05:22 AM
hi
I think this error normally arises when SQL server is not running.
if so, start SQL server (using service Manager or..).

excuse if I'm wrong

regards
afterMoon

steve_rm
Apr 30th, 2003, 05:29 AM
Hello

Thanks for you response.

Yes l have tried with SQL running, that was the first thing l tried when l got the error.

I think it might have something do with read and write permissions. But l am new to SQL Server, so not sure how to do that. If that is what is causing the error.

Any suggustions

Steve

afterMoon
Apr 30th, 2003, 06:21 AM
Hi
try using the following connection string. may be you are using sql server authentication.

"User Id=UserName;Pwd=password; Data Source= ServerName;Initial Catalog =DataBaseName; Persist Security Info=false"

hope this will help

afterMoon

steve_rm
Apr 30th, 2003, 08:30 AM
Hello

Thanks for you response.

I will try that connection string in my program.

Can you tell me what does all that mean in the connection string. Seems very complicated. It is different to my one.

"User Id=UserName;Pwd=password; Data Source= ServerName;Initial Catalog =DataBaseName; Persist Security Info=false"

Thanks

fungi
Apr 30th, 2003, 10:21 AM
This could be similar to the same problem you were having getting connected to Access.

Your original connection string is using trusted security which means Windows authentication will be used when you open a SQL connection. Unless you've changed your impersonation setting it is likely trying to connect using the ASPNET account.

So you could set-up ASPNET as a valid SQL Server login/db user.

Or you could connect using SQL Server authentication which is what aftermoon is getting at. In this case you supply the login info as part of the connection string.

Hope this helps

steve_rm
May 1st, 2003, 02:45 AM
Hello

I am using this connection string, but still getting the same problem. Not sure what l am doing wrong here.


Dim objConnection As New SqlClient.SqlConnection("server=STEVES-PC\NETS; Initial Catalog =keepFit; User ID =UserName; Password = MyPassword; Persist Security Info =false")


Setting up an ASPNET as a valid SQL server login/db user. I did this for access on the folder where the database is located. When l do this for for SQL is it the same way? Where would the database be on my computer? A step by step guide would be most helpful. I am a beginner.

A have attached a tree view of my server explorer. This might help as well

Many thanks for all your help

Steve

steve_rm
May 1st, 2003, 03:02 AM
Server Explorer attachment

steve_rm
May 1st, 2003, 03:08 AM
Server Explorer attachment

afterMoon
May 1st, 2003, 03:45 AM
Hi

use 'Data Source' instead of 'server' in the connection string.

afterMoon
May 1st, 2003, 04:19 AM
If u have the sql server authentication use the connection string which I sent first.
In that
User ID is the username of sqlserver
Pwd is the password of user if any; else put pwd=;
Data Source is your servername
Initial Catalog is your database name


if u need to set up ASPNET as valid sqlserver user do the following.In this case you may use your original connection string(but I'm not sure)

1. From your enterprise manager choose your server from the explorer.
2.Explore the Security folder
3.Right click on Logins, select new login
4. from the general tab,click on browse button of name.
5. select ASPNET, and add.
6. and in the defaults section below, select your database instead of master. or from database access tab, give permission
to your database

for connection strings go to www.connectionstrings.com
regards

afterMoon

steve_rm
May 1st, 2003, 04:33 AM
Hello

Thanks for you help.

I will give that a try when l get home, and let you know how get on.

Getting there slowly, but learning all the time.

Steve