-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getFilename() -Error #437
Comments
Error reading characters of string. |
please provide the following information:
|
Thank you for your information.
The compiler name and version are "Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.5.5".
OS-Microsoft Windows 10 Professional, Version-10.0.19045
Build System : MSBuild
I was building the project with Qt in Visual Studio(Using qt plugin).
The following is the code block
```
void (CANDeviceInit:: * ptr_data_signal_2)(const std::vector<ZCANDataObj> &receive_data, UINT length) = &CANDeviceInit::CANDataSignal;
void (CenterWidget:: * ptr_data_receive_2)(const std::vector<ZCANDataObj> &receive_data, UINT length) = &CenterWidget::ReceiveCANData;
connect(this->dev, ptr_data_signal_2, this, ptr_data_receive_2);
void CenterWidget::ReceiveCANData(const std::vector<ZCANDataObj>& receive_data, UINT length)
{
std::string database_name = "database";
std::string table_name = "table_name";
SaveToDatabase(database_name, table_name, receive_data, length);
}
void CenterWidget::SaveToDatabase(
const std::string database_name,
const std::string table_name,
const std::vector<ZCANDataObj>& receive_data,
UINT length)
try {
// Open a database file in create/write mode
SQLite::Database database((database_name + ".db3").c_str(), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE); // Error reading characters string
LOG(INFO) << "SQLite database file '" << database.getFilename().c_str() << "' opened successfully\n";
// Execute SQL statements created by tables
const std::string kCreatTable = "CREATE TABLE IF NOT EXISTS "
+ table_name
+ "(Timestamp INTEGER PRIMARY KEY, Direction TEXT, ID TEXT, Length INTEGER, Data TEXT)";
database.exec(kCreatTable.data());
}
}
```
Please let me know what you think.
Best Regards
From: Jonathan Guzmán
Date: 2023-08-17 12:43
To: SRombauts/SQLiteCpp
CC: DuanZhaobing; Author
Subject: Re: [SRombauts/SQLiteCpp] getFilename() -Error (Issue #437)
please provide the following information:
compiler name
compiler version
OS
build system: cmake, meson, etc.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Hello, I don't see anything wrong with how you use SQLiteCpp, only minor improvements that could be made to your code. I copy pasted and slightly adapted your code to run in the
The output starts with the expected log:
|
Hello sir. I used the same code in Visual Studio to create a new C++ Console App and a Qt Empty App, but with different results. I don't have enough experience to look further into the cause. And I don't know if it's a problem with my usage or something else.
|
can you upload a sample repo with the code that throws the error? |
Hello Sir. |
seems that it could be caused for the following reasons:
for the example repo is recommended that you also show the example of your QT app, or at least a minimal failing example that we can debug |
Sorry to have kept you waiting, Sir. |
SQLite::Database dbs("hello.db3", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
auto db_name = dbs.getFilename().c_str();
When I use the above code to create and get the database file name, the compiler prompts an error and cannot get the relevant value.
SQLiteCpp/include/SQLiteCpp/Database.h
Line 465 in 164a606
The text was updated successfully, but these errors were encountered: