|
-
Apr 30th, 2003, 04:24 AM
#1
Thread Starter
Frenzied Member
SQL server does not exist or access denied
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
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
-
Apr 30th, 2003, 05:22 AM
#2
Lively Member
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
when in doubt, win the trick
-
Apr 30th, 2003, 05:29 AM
#3
Thread Starter
Frenzied Member
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
-
Apr 30th, 2003, 06:21 AM
#4
Lively Member
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
when in doubt, win the trick
-
Apr 30th, 2003, 08:30 AM
#5
Thread Starter
Frenzied Member
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
-
Apr 30th, 2003, 10:21 AM
#6
Hyperactive Member
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
-
May 1st, 2003, 02:45 AM
#7
Thread Starter
Frenzied Member
Hello
I am using this connection string, but still getting the same problem. Not sure what l am doing wrong here.
Code:
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
-
May 1st, 2003, 03:02 AM
#8
Thread Starter
Frenzied Member
Server Explorer attachment
-
May 1st, 2003, 03:08 AM
#9
Thread Starter
Frenzied Member
Server Explorer attachment
-
May 1st, 2003, 03:45 AM
#10
Lively Member
Hi
use 'Data Source' instead of 'server' in the connection string.
when in doubt, win the trick
-
May 1st, 2003, 04:19 AM
#11
Lively Member
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
when in doubt, win the trick
-
May 1st, 2003, 04:33 AM
#12
Thread Starter
Frenzied Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|