?
Solved

Can't connect via dblib but can via ODBC.

Posted on 2004-10-20
6
Medium Priority
?
399 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

764 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