How to connect to SQL Database server using MFC CDataBase object

Darsi, Sanjay Kumar 41 Reputation points

Hi Team,
I have a project with MFC where they are connecting to the SQL server using the class CDatabase
and CRecordset.
At present i am using DSN as the part of the connection string. Now i want to establish the connection using the CDataBase without the need of DSN.

I tried to use ADO but not useful because of some architecture change is required.
Can anyone suggest how can i achieve connection to sql server database using CDatabase without DSN and is it possible or not?


Azure SQL Database
0 comments No comments
{count} votes

Accepted answer
  1. Mike Ubezzi 2,776 Reputation points

    @Darsi, Sanjay Kumar - Please take a look at the Database Support, MFC Application Wizard in Visual Studio. It will guide you through creating the necessary database support.

    If you select ODBC under Client type, then the application's view class derives from CRecordView. This class is associated with a CRecordset-derived class, which the MFC Application Wizard also creates for you. This option gives you a form-based application in which the record view is used to view and update records through its recordset.

    Please use comments below to ask any additional questions. ~Mike

    0 comments No comments

0 additional answers

Sort by: Most helpful