Results 1 to 12 of 12

Thread: SQL server does not exist or access denied

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    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
    steve

  2. #2
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    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
    steve

  4. #4
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    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

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    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
    steve

  6. #6
    Hyperactive Member
    Join Date
    Jan 2003
    Location
    Cape Cod, US
    Posts
    292
    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

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    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
    steve

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    Server Explorer attachment
    steve

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    Server Explorer attachment
    steve

  10. #10
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    Hi

    use 'Data Source' instead of 'server' in the connection string.
    when in doubt, win the trick

  11. #11
    Lively Member afterMoon's Avatar
    Join Date
    Oct 2002
    Location
    cochin
    Posts
    117
    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

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331
    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
    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
  •  



Click Here to Expand Forum to Full Width