Groups | Blog | Home
all groups > sql server odbc > june 2007 >

sql server odbc : SQL server database access from VC++


Manjree Garg
6/6/2007 2:33:00 AM
Hi

I am new to SQL server and ODBC. I am trying to retrieve SQL server database
using VC++ (using VS.net). I am using SQLConnect to connect to the SQL
server. My code contains

SQLAllocEnv(&henv);
SQLAllocConnect(henv,&hdbc);
rc=SQLConnect(hdbc,chr_ds_name,SQL_NTS,NULL,0,NULL,0);

I have included the following files

#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <stdlib.h>
#include <mbstring.h>

but the problem is that its giving linker error
error LNK2019: unresolved external symbol _SQLAllocStmt@8 referenced in
function "public: void __thiscall CDataAccess::sqlconn(void)"
(?sqlconn@CDataAccess@@QAEXXZ)

I guess I am missing some file that it should be linked to. Any help would
changliw NO[at]SPAM online.microsoft.com
6/7/2007 2:32:33 AM
Hi,
I understand that you encountered the link error when you built your VC++
codes which used ODBC API to acces SQL Server database.
If I have misunderstood, please let me know.

This is a link error, so I would like to confirm with you whether or not
you import the odbc32.lib into your project.
If not, please right click your project in Solution Explorer, click
Properties, in the property window, expand Linker, select Additional
Dependencies, and input the odbc32.lib (C:\Program Files\Microsoft
SDKs\Windows\v6.0\Lib) to the field. If you directly input odbc32.lib
without specifying the folder path, please ensure that the library folder
path has been added into the VC++ Directories. Select
Tools->Options->Projects and Solutions -> VC++ Directories -> Library files.

Hope this helps. If you have any other questions or concerns, please feel
free to let me know. Have a good day!

Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications

If you are using Outlook Express, please make sure you clear the check box
"Tools/Options/Read: Get 300 headers at a time" to see your reply promptly.


Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================




changliw NO[at]SPAM online.microsoft.com
6/11/2007 12:00:00 AM
Hi,
I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Charles Wang
Microsoft Online Community Support

======================================================
When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
Manjree Garg
6/11/2007 5:32:00 AM
Thanks Charles. The suggestion worked. odbc32.lib must be included.

Manjree

[quoted text, click to view]
AddThis Social Bookmark Button