Solved

Can't connect via dblib but can via ODBC.

Posted on 2004-10-20
6
381 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
Comment Utility
Not worked with DBLIB, so this is just a guess.... do you need to set DBSETLHOST?
0
 

Author Comment

by:arichexe
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:arichexe
Comment Utility
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
Comment Utility
Localhost should be OK... unless you've got a local firewall (e.g. XP SP2)
0
 

Author Comment

by:arichexe
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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++.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now