Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How can i start with database programming in C++ or VC++ without MFC and without any third party library. I just want to use the prebuilt libraries provided in visual studio by Microsoft.


What I have tried:

I have tried a lot. Googled. Not found anything.
Posted
Updated 20-Apr-19 11:28am

A simple way would be to use DataTables, see example: Visual C++ .NET Databases: Introduction to Data Tables[^]
Or write your own database, see tips here: sql - How to write a simple database engine - Stack Overflow[^]
This looks interesting too: GitHub - simdb: A single file, no dependencies, C++11 key-value store[^]
Good luck, hehehe :)
 
Share this answer
 
v4
The most efficient way for doing so would be using SQLite3[^].
This is an open source project. The Windows version doesn't require any additional framework and you can use it with plain Win32 API.
SQLite3 lacks proper support for UNICODE, so I usually use a wrapper called CppSqlite3[^] which is also very simple and straight forward.

Here is an example I wrote:
// An example for updating a record: Update or Replace the value of FieldValue in field FieldName
bool UpdateRecord(bool UpdateOnly, CString FieldName,CString FieldValue)
{
	CppSQLite3DB temp;
	temp.open(DBName);


	CString sql;
	if (UpdateOnly)
	{
		sql = (CString)L"UPDATE log " + (CString)L" SET " + FieldName + L" = " + FieldValue;
	}
	else
	{
		sql = L"REPLACE INTO log (" + FieldName + L") VALUES ('" + FieldValue + L"')";
	}

	CppSQLite3Query SqlQuery;
	try
	{
		SqlQuery = temp.execQuery(sql);
	}
	catch (CppSQLite3Exception & e)
	{
		temp.close();
		return false;
	}
	temp.close();
	return true;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900