VB2008 connecting error 40

  • I'm working with VMWare and made a new installation, lets say in VM2, with Win7-Pro 64 bit, VS2008 Standard Edition, SS2008 Standard

    Edition. I wrote a VB2008-program accessing the SS2008-DB. When I debug all works fine.

    In a second VM, lets say VM4, I installed WinXP-Pro SP3, VS2005 Professional Edition, SS2005 Developer Edition. For the program created

    in VM1 I created a setup from within VS2008. The setup/MSI-files are then manually copied from VM2 to VM4 and setup is launched. No

    errors.

    But when I start my app I get

    "...Named pipes provider, error 40 - Could not open a connection to SQL Server)".

    I was googling around for two days and couldn't find a solution.

    What I did in VM4:

    1. disabled Windows-Firewall

    2. Named pipes and TCP/IP are activated

    3. checked TCP/IP port 1433 is active

    4. tried with ";Network Library=dbmssocn" but no success

    5. downloaded a trial version for setups (MSI-Factory), created setup-files, but no success

    6. when i use sqlcmd or osql I can reach the database in VM4!

    This is the connection string in VM2 (no errors):

    "Data Source=PC9-VM02-W7-64;Initial Catalog=DB_TRACKIT_PLUS;Integrated Security=True"

    in VM4 (=>error)

    "Data Source=PC9-VM04-WINXP;Initial Catalog=DB_TRACKIT_PLUS;Integrated Security=True"

    Now I'm stuck :w00t: Any hints?

    --
    candide
    ________Panta rhei

  • Hello,

    I found out it's not connecting to SQL-Server whats the problem and I was searching in wrong direction.

    I talked with another developer and he gave me the right hint. So for all VS2008-beginners out there here the answer:

    When working on your developer machine the SQL connection string has a certain value. Right.

    You wanna roll out your app for your customer and as a beginner you think just set the SQL connection string to your customers value in a forms load event, make a "conn.open()" and thats it. But thats the crux of matter.

    You CAN'T simply set the connection string in load-event to toggle around between developer PC and customer PC. It doesn't work. I read a bunch of books and there was never a hint in this direction. Ok beginner faults happen. Thats life.

    Solution is if you make your VS2008-setup-files just change the value for SQL connection string manually. Ok it's a workaround and now I know you can create a constructor for a form and then change this SQL connection string per code. WHOOF. Coming from MS-Access this sounds more complicated than I wish.

    I thought new developer tools should make our life easier. Searching for this error cost me three days:angry:. Someone in web wrote Visual Studio/MSDN is like a monster.:crying: I still think about it. Maybe...

    nice weekend for all readers

    --

    candide

    --
    candide
    ________Panta rhei

  • Put it down to experience: I've had similar problems with connections, and I still get caught out, and have to go investigating all those settings - in fact it bugged me so much I made my own checklist:

    ping (physical connection present?)

    firewall (allowed in?)

    config manager

    port setting

    TCP setting

    try connect by IP address

    server logins

    database users

    any one of these can trip you up.

    Next time you come across this (and you probably will) you'll be able to solve it much quicker.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply