I'm making a class in c++-cli, and I added an extra argument to one of my functions. The name of the extra argument was int row,and when I add that I get this error:
LNK2022 metadata operation failed (80131187) : Inconsistent method declarations in duplicated types (types: query; methods: Read_DB)
When I remove that extra argument I added, the error goes away. If I remove the argument column_index, it also goes away. But if I remove one of the String^ arguments, it still stays. I'm not sure what the error is, here's both my .h and the functions definition in the .cpp file of code:
Header:
#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 file:
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;
}
to fix the problem I just deleted the debug folder and restarted my application. It had something to do with changing the name of the object.