Solved

Can't connect via dblib but can via ODBC.

Posted on 2004-10-20
6
396 Views
Last Modified: 2008-01-09
I'm getting the below error when attempting to connect to a certain SQL Server, even though it appears to be set up exactly like all my others.  What could be causing this?  I can connect fine via VB ODBC, but not via C++ dblib.

C++:
  dbinit()
  login = dblogin();
  DBSETLUSER(login,(char *)"testuid");
  DBSETLAPP(login,(char *)"testapp");
  DBSETLPWD(login,(char *)"testpwd");
  DBSETLVERSION(login,DBVER60);
  dbproc = dbopen(login,"testsvr")  }
  dbuse(dbproc,"testdb");

  DB-Library Error 10004: Unable to connect: SQL Server is unavailable or does not exist.  Unable to connect: SQL Server does ...

VB:
  conn.Open "driver={SQL Server};server=testsvr;uid=testuid;pwd=testpwd;database=testdb"

  Connects Successfully
0
Comment
Question by:arichexe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:rstaveley
ID: 12367068
Not worked with DBLIB, so this is just a guess.... do you need to set DBSETLHOST?
0
 

Author Comment

by:arichexe
ID: 12371604
The host is the server name correct?  Anyway, I tried that to no avail.  If it's any help, the SQL Server is local, on the server that runs the dblib code.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 12371721
Just Googled this up:

http://www.win2000mag.com/sqlserver/forums/messageview.cfm?catid=1664&threadid=119462

It might be worth following the procedure indicated by the author at the end.

Sorry, I'm not being very helpful.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:arichexe
ID: 12373392
I just heard from my SA that port 1433 is closed, so as to disallow network connections to MSSQL.  Could this be why I can't connect via dblib, but can via ODBC, even though I'm running directly on the box?
0
 
LVL 17

Accepted Solution

by:
rstaveley earned 125 total points
ID: 12373557
Localhost should be OK... unless you've got a local firewall (e.g. XP SP2)
0
 

Author Comment

by:arichexe
ID: 12375034
I figured it out.  The actual name of the server is "testsvr."  I was missing the period.  Apparently, dblib uses the server name, not the SQL Server name to connect.  Weird, huh?
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question