Solved

Can't connect via dblib but can via ODBC.

Posted on 2004-10-20
6
387 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
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

829 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