Results 1 to 9 of 9

Thread: Can't connect to database [resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5

    Resolved Can't connect to database [resolved]

    Hi guys and gals!

    I was wondering if anyone could help me? I'm using a book called "Karl Moore's Visual Basic .NET: The Tutorials" and getting on great with it..... but for one thing!

    I can't seem to connect to the database I need to use (I know it works cos I can manually add data to it)

    I'm using the following connection string, as prescribed by the book:

    Dim objConnection As New SqlClient.SqlConnection _
    ("server=.;database=KeepFit;trusted_connection=true")

    Whenever I try to run this, I just get an error message saying SQL Server does not exist or access denied.

    Any help you can give would be very very much appreciated

    Thanks
    Last edited by d1lb3rt; Oct 15th, 2004 at 11:44 AM.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Dim objConnection As New SqlClient.SqlConnection _
    ("server=.;database=KeepFit;trusted_connection=true")

    well unless the name of the SQL Server is "." I can see exactly why this wouldn't work.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5
    the dot signifies that the instance of the server is on the local machine, as quoted in Karl's book. When I set a breakpoint, I can see it is looking at the right place. Even when I substitute the full server name, I get the same message.

  4. #4
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036
    Hi

    Try removing trusted_connection=False and add the username and password in the connection string.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5

    Unhappy

    Thanks for the suggestion, but I don't have a user name or password. I'm not using the full SQL server, it's just MSDE that comes with VS.NET - unless you know of what the default user name and password are? If it helps, my database was set up using windows security rather than a specific uname and pwd.

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    did you name the instance of the MSDE when you installed it?

  7. #7

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5
    I didn't get the opportunity - it just went in as potter\netsdk

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    maybe you should add a SQLConnection control onto a form and setup a connection that way... the system will do a lot of the work for you.. then once you have made a successful connection, you can look at the connection string it is using, and use that in your code.. the SQLConnection object can be found under the data tab in the toolbox

  9. #9

    Thread Starter
    New Member
    Join Date
    Oct 2004
    Posts
    5

    [solved]

    Managed to fix it with the help of another web site - I had to manually grant myself access to the database before I could do anytyhing.

    Thanks for all your help guys!

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