' - > ToString'左边的错误必须指向class / struct / union / generic类型 [英] error left of '->ToString' must point to class/struct/union/generic type
本文介绍了' - > ToString'左边的错误必须指向class / struct / union / generic类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是视觉c ++编码的nwebie。在下面的代码我面临这个错误,我不知道如何解决这个问题,为什么会发生这种情况
String ^ constring = L" datasource = 127.0.0.1; port = 3306; username = root; password = 1965" ;;
MySqlConnection ^ conDatabase = gcnew MySqlConnection(constring);
MySqlCommand ^ cmdDatabase = gcnew MySqlCommand(" SELECT * FROM`database`.edata其中Username ='" + this-> username_txt-> Text +"'和password ='" + this- > password_txt->文字+ QUOT;';",conDatabase);
MySqlDataReader ^ myReader;
try
{
conDatabase-> Open();
myReader = cmdDatabase-> ExecuteReader();
int count = 0;
while(myReader-> Read())
{
count = count + 1;
}
if(count == 1)
{
MessageBox :: Show(myReader-> Read() - > ToString()); ///此行是否引起了我所提到的错误
this-> Hide();
MyForm1 ^ f1 = gcnew MyForm1();
f1-> ShowDialog();
}
if(count> 1)
{
MessageBox :: Show(" duplicate username and password");
}
else
{
MessageBox :: Show("用户名或密码错误);
}
}
catch(Exception ^ ex)
{
MessageBox :: Show(ex-> Message);
}
}
请帮我弄清楚发生了什么。
解决方案
我是视觉c ++编码的nwebie。在下面的代码我面临这个错误,我不知道如何解决这个问题,为什么这个
发生
< pre class ="prettyprint"> String ^ constring = L" datasource = 127.0.0.1; port = 3306; username = root; password = 1965" ;;
MySqlConnection ^ conDatabase = gcnew MySqlConnection(constring);
MySqlCommand ^ cmdDatabase = gcnew MySqlCommand(" SELECT * FROM`database`.edata其中Username ='" + this-> username_txt-> Text +"'和password ='" + this- > password_txt->文字+ QUOT;';",conDatabase);
MySqlDataReader ^ myReader;
try
{
conDatabase-> Open();
myReader = cmdDatabase-> ExecuteReader();
int count = 0;
while(myReader-> Read())
{
count = count + 1;
}
if(count == 1)
{
MessageBox :: Show(myReader-> Read() - > ToString()); ///此行是否引起了我所提到的错误
this-> Hide();
MyForm1 ^ f1 = gcnew MyForm1();
f1-> ShowDialog();
}
if(count> 1)
{
MessageBox :: Show(" duplicate username and password");
}
else
{
MessageBox :: Show("用户名或密码错误);
}
}
catch(Exception ^ ex)
{
MessageBox :: Show(ex-> Message);
}
}
请帮我弄清楚发生了什么以及如何解决这个问题。
I am a nwebie in visual c++ coding.In the following code I am facing this error,I don't know how to solve this and why is this happening
String^ constring = L"datasource=127.0.0.1;port=3306;username=root;password=1965"; MySqlConnection^ conDatabase = gcnew MySqlConnection(constring); MySqlCommand ^ cmdDatabase = gcnew MySqlCommand(" SELECT * FROM `database`.edata where Username='"+this->username_txt->Text+"' and password='"+this->password_txt->Text+"';",conDatabase); MySqlDataReader^ myReader; try { conDatabase->Open(); myReader = cmdDatabase->ExecuteReader(); int count = 0; while (myReader->Read()) { count = count + 1; } if (count == 1) { MessageBox::Show(myReader->Read()->ToString());///THIS LINE IS CAUSING ERROR WHICH I HAVE MENTIONED this->Hide(); MyForm1^ f1 = gcnew MyForm1(); f1->ShowDialog(); } if (count > 1) { MessageBox::Show("duplicate username and password"); } else { MessageBox::Show("wrong username or password"); } } catch (Exception ^ex) { MessageBox::Show(ex->Message); } }
Please help me to figure out what's going on.
解决方案
I am a nwebie in visual c++ coding.In the following code I am facing this error,I don't know how to solve this and why is this happeningString^ constring = L"datasource=127.0.0.1;port=3306;username=root;password=1965"; MySqlConnection^ conDatabase = gcnew MySqlConnection(constring); MySqlCommand ^ cmdDatabase = gcnew MySqlCommand(" SELECT * FROM `database`.edata where Username='"+this->username_txt->Text+"' and password='"+this->password_txt->Text+"';",conDatabase); MySqlDataReader^ myReader; try { conDatabase->Open(); myReader = cmdDatabase->ExecuteReader(); int count = 0; while (myReader->Read()) { count = count + 1; } if (count == 1) { MessageBox::Show(myReader->Read()->ToString());///THIS LINE IS CAUSING ERROR WHICH I HAVE MENTIONED this->Hide(); MyForm1^ f1 = gcnew MyForm1(); f1->ShowDialog(); } if (count > 1) { MessageBox::Show("duplicate username and password"); } else { MessageBox::Show("wrong username or password"); } } catch (Exception ^ex) { MessageBox::Show(ex->Message); } }Please help me to figure out what's going on and how to solve this issue.
这篇关于' - > ToString'左边的错误必须指向class / struct / union / generic类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文