Solved

Can't connect via dblib but can via ODBC.

Posted on 2004-10-20
6
384 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

778 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