如何在没有MFC且没有任何第三方库的情况下从C ++或VC ++开始数据库编程。 [英] How can I start with database programming in C++ or VC++ without MFC and without any third party library.
本文介绍了如何在没有MFC且没有任何第三方库的情况下从C ++或VC ++开始数据库编程。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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.
推荐答案
一种简单的方法是使用 DataTables ,参见示例: Visual C ++ .NET数据库:数据表简介 [ ^ ]
或者编写自己的数据库,请参阅此处的提示: sql - 如何编写简单的数据库引擎 - Stack Overflow [ ^ ]
这看起来也很有趣:< a href =https://github.com/LiveAsynchronousVisualizedArchitecture/simdb> GitHub - simdb:单个文件,没有依赖关系,C ++ 11键值存储 [ ^ ]
祝你好运,呵呵呵:)
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 :)
最有效的方法是使用 SQLite3 [ ^ ]。
这是一个开源项目。 Windows版本不需要任何额外的框架,你可以使用普通的Win32 API。
SQLite3缺乏对UNICODE的适当支持,所以我通常使用一个名为CppSqlite3 [ ^ ]这也很简单直接。
这是我写的一个例子:
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;
}
这篇关于如何在没有MFC且没有任何第三方库的情况下从C ++或VC ++开始数据库编程。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文