I got some good help for you.
I ran into the same problem.
The online help in VC5.0 on SQL server gives many choices, but
few if any are up to date with the ODBC 3.0 drivers.
I am assuming by the function call that you are using ODBC.
Find out which version of the ODBC driver you are using, (i.e. 2.0,
2.5,3.0).
This is important because Microsoft made a huge revision of the ODBC driver
in the ODBC 3.0 version. They replaced a lot of the functions with new
ones
and got ride of some of the old functions by just incorporating the
parameters
into existing functions. :) don't you just love it.
so now there is confusion when you use the online help. Even in the
SQLServer
online help.
My biggest recommendation to you is to go to the Microsoft site and
download
the ODBC 3.0 programmer's reference manuals which will give you an
updated version of the ODBC 3.0 online help. The site is:
http://www.microsoft.com/odbc/download.htm
so to make a long story short, below is my SQLConnect statement.
Hope this helps.
-------------------------
retcode = SQLAllocEnv(&henv); /* Environment handle */
/* Allocate the connection handle */
retcode = SQLAllocConnect(henv, &hdbc); /* Connection handle */
if (retcode == SQL_SUCCESS) {
/* Set login timeout to 5 seconds. */
SQLSetConnectAttr(...);
/* Connect to data source */
retcode = SQLConnect(hdbc, szDSN, SQL_NTS, username, SQL_NTS,
password, SQL_NTS);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){
... the rest of the code.
Note that szDSN is an array which contains the name of the dsn to which
I am connection. username and password are also variables which are
self explainable. If you use literals in the SQLConnection statement as
parameters, you must type cast them to (UCHAR*).
Good Luck
SouXie
Soft. Eng.
Intellisys
--
Quote:> Hi,
> I am trying to connect to SQL Server using SQLConnect in VC++ 5.0. THe
> program does not compile. I get errors like ...
> SQLConnect does not accept 3 parameters
> When I tried to look into the VC++ help for SQLConnect it gave me 3
> choices and one of those says that SQLConnect accepts 6 parameters and
> the other one says it accepts 3 parameters. Is this an overloaded
> function. Also, I tried compiling their sample program but could not.
> If anyone could shed any light on this topic it would great ....
> Is there a specific documentation on ODBC. ANy suggestions would be
> great....
> Thankx ...
> - Ash
> --