Results 1 to 13 of 13

Thread: sql server does not exist - oh but it does!

  1. #1

    Thread Starter
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    sql server does not exist - oh but it does!

    Guys

    I have a couple of lines of code:

    VB Code:
    1. if request.servervariables("HTTP_HOST") = "localhost" Then
    2.     strConnex = "Provider=sqloledb;SERVER=MyLapTop;UID=MyUID;PWD=MyPWD;DATABASE=MyDB"
    3. else
    4.     strConnex = "Provider=sqloledb;SERVER=mywebserver;UID=MyUID;PWD=MyPWD;DATABASE=MyDB"
    5. End if

    which, on my laptop (MyLapTop) works just fine. I have another machine, however, sitting right next to me on the same network that can open and query the database on my laptop from Enterprise Manager/Query Analyser however when I try to use the bit of code above I get the error:

    Microsoft OLE DB Provider for SQL Server (0x80004005) [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

    This is when I try to open the connection using:

    VB Code:
    1. Set counterConn = Server.CreateObject("ADODB.Connection")
    2.             counterConn.open strConnex

    If, however, I comment out the test for localhost and go straight out the the webserver database then that connects ok.

    Any ideas?!

    Incidentally, I'm pretty sure that this worked before I went on holiday. I don't know, leave a network engineer in charge of things for 2 weeks and look what happens......!
    Last edited by thebloke; Jul 22nd, 2005 at 06:12 AM.
    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

  2. #2
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016

    Re: sql server does not exist - oh but it does!

    Are you defining the server in your connection string to be "SERVER=(local)" when you are on your laptop, or "SERVER=ComputerName"?

    I'm assuming that the machine next to you is NOT your webserver. If that's the case and you have the connection string defined as "SERVER=(local)", then you'll get that error if SQL Server isn't running on that machine.
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  3. #3

    Thread Starter
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    Re: sql server does not exist - oh but it does!

    The connection string on both machines is the same; both define the local server as the computer name of the laptop MyLapTop where the database is....
    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: sql server does not exist - oh but it does!

    VB Code:
    1. if request.servervariables("HTTP_HOST") = "localhost" Then
    I think that's what's failing you.
    Given that code, I'm assuming you are running an ASP page, right? When you run it on the laptop, is it actualy running on the laptop, or from the other machine? And when running it from the other machine, is it running on that machine, or on the laptop?

    In other words, when you run the page, how are you accessing it? http://localhost ?? or http://some.ip.addr.here or ??????

    I'm wondering if it thinks that the server variable in both cases is localhost and tries to use the first connectionstring.

    Have you tried to response.write the connection string before opening it? That might give some clue as to what connectionstring it really is using.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    Re: sql server does not exist - oh but it does!

    No, it's 2 different pages. Each running on it's own machine. That bit of the code is correct. It's just so that when I stick it live I don't have to mess around changing connection strings.
    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: sql server does not exist - oh but it does!

    So, do you have SQL Server on both machines?
    It sounds like you have PageA on MachineA and PageB on MachineB.... both of which think they are "localhost"..... and so try to connect to "local" server. But you want PageB to connect to database on MachineA. So checking for localhost isn't quite going to work.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    Re: sql server does not exist - oh but it does!

    pageA is on machineA and pageB is on machineB, yes. However I need pageB to connect to the database on machineA if pageB is running on machineB and not on my live web server (machineC, if you like).
    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

  8. #8
    Fanatic Member vb_dba's Avatar
    Join Date
    Jun 2001
    Location
    Somewhere aloft between the real world and insanity
    Posts
    1,016

    Re: sql server does not exist - oh but it does!

    Quote Originally Posted by techgnome
    Have you tried to response.write the connection string before opening it? That might give some clue as to what connectionstring it really is using.

    Tg
    Have you verified that on machineB it is using the correct connection string?
    Chris

    Master Of My Domain
    Got A Question? Look Here First

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: sql server does not exist - oh but it does!

    D'uh.... Gotcha now.... sorry I was being a bit thick.....

    Still, have you tried to print out the connection string before opening the connection? --just to make sure it is in fact connecting to the machine you think it is...


    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10

    Thread Starter
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    Re: sql server does not exist - oh but it does!

    Yup, I've done that.
    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

  11. #11
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: sql server does not exist - oh but it does!

    Sorry to butt in....

    Do you have a firewall on the maachine with the database?
    Just wondering if it is (for some reason) blocking the connection...

    You did say direct connection works, but that may be ok through the firewalll if you have one, where as the HTML/IIS link might need a specific permission, like when you allow people to view folders with actions etc ...

    Just a thought, sorry if it has nothing to do with it.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  12. #12

    Thread Starter
    Hyperactive Member thebloke's Avatar
    Join Date
    May 2003
    Posts
    358

    Re: sql server does not exist - oh but it does!

    You know what? You're a star! Some munter appears to have switched my windows firewall on on my laptop while I was sunning myself in Spain. Just switched it off and job's a good 'un.

    Good man, yourself.

    Thanks guys for all of your help.

    The Bloke
    www.blokeinthekitchen.com
    making cooking cool for blokes

  13. #13
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: sql server does not exist - oh but it does!

    You know, I thought about that, but when it was mentioned that a direct connect worked, I dicounted that.... That'll learn me. Sometimes it's the simplest of things.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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