c++-cli - 重复类型中的方法声明不一致
问题描述
我在 c++-cli 中创建一个类,并为我的一个函数添加了一个额外的参数。额外参数的名称是 int row,当我添加时,我得到了这个错误:
LNK2022 元数据操作失败 (80131187):重复类型中的方法声明不一致(类型:查询;方法:Read_DB)
当我删除我添加的额外参数时,错误就消失了。如果我删除参数 column_index,它也会消失。但是,如果我删除其中一个 String^ 参数,它仍然存在。我不确定错误是什么,这是我的 .h 和 .cpp 代码文件中的函数定义:
标题:
#ifndef DATA_BASE
#define DATA_BASE
using namespace System;
using namespace System::Data::SqlClient;
ref class ConnectDB{
protected:
SqlConnection^ cnn;
bool state;
public:
String^ db;
bool ConnectDataBase();
bool DisconnectDataBase(void);
};
ref class Query : public ConnectDB {
private:
~Query(void);
public:
bool Create_Table(String^ name, String^ columns);
String^ Read_DB(String^ column, String^ table, int column_index, int row);
bool Write_DB(String^ path, String^ msg);
};
#endif
cpp文件:
String^ Query::Read_DB(String^ column, String^ table, int column_index, int row) {
String^ output;
String^ sql = "SELECT " + column + " FROM " + table;
try {
SqlCommand^ command;
SqlDataReader^ dataReader;
command = gcnew SqlCommand(sql, cnn);
dataReader = command->ExecuteReader();
std::cout << "Reading data from Database...\n";
int counter;
while (dataReader->Read()) {
counter++;
if(counter == row)
output = (String^)dataReader->GetValue(column_index);
}
//command->Dispose();
dataReader->Close();
}
catch (Exception^ e) {
Console::WriteLine(e);
std::cout << "Failed to query database\n";
return "0";
}
return output;
}
解决方案
为了解决这个问题,我刚刚删除了调试文件夹并重新启动了我的应用程序。它与更改对象的名称有关。
推荐阅读
- node.js - 如何使用 square/go-jose 包验证 JWS
- javascript - 如何在 JavaScript 中合并两个对象的值
- java - 使用 Java 接收 DJI Tello 的视频流
- java - 在java中捕获视频第一帧文件
- python - Python matplotlib:旋转条形图的 x 轴标签
- powershell - 如何在后台运行 powershell 脚本并接收 toast 通知?
- reactjs - 如何使用 prevState 所以我不必使用 setTimeout
- sql-server - 如何使用 T-SQL 查询仅获得每个 SSIS 作业的最后一次运行?
- javascript - 如何将 API 数据动态传递给 MongoDB 数据库
- apache-kafka - 墓碑和密钥存储清理