error C2446: '==' : no conversion from 'int' to 'System::String ^'

This is a discussion on error C2446: '==' : no conversion from 'int' to 'System::String ^' within the Windows Programming forums, part of the Platform Specific Boards category; Hi guys, I am having a trouble with the boolean. I am trying to get access to my website script ...

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    40

    error C2446: '==' : no conversion from 'int' to 'System::String ^'

    Hi guys,

    I am having a trouble with the boolean. I am trying to get access to my website script and see if it have response through the httpwebrequest method, then check if the bool is valid then login to the system to receive the information.



    Code:
    private: System::Void Button1_Click(System::Object^ sender, System::EventArgs^ e) {
    
           try
          {
            //Address of URL
            String ^URL = "http://www.mysite.com/myscript.php?user=" + TextBox1->Text + "&pass=" + TextBox2->Text;
            HttpWebRequest ^request = safe_cast<HttpWebRequest^>(WebRequest::Create(URL));
            HttpWebResponse ^response = safe_cast<HttpWebResponse^>(request->GetResponse());
            StreamReader ^reader = gcnew StreamReader(response->GetResponseStream());
            String ^str = reader->ReadToEnd();
            <br/>
            if (request->HaveResponse)
            {
              MessageBox::Show("connected ok, now let login!");
              try
              {
                //Address of URL
                String ^URL1 = "http://www.mysite.com/myscript.php?user=" + TextBox1->Text + "&pass=" + TextBox2->Text;
                HttpWebRequest ^request1 = safe_cast<HttpWebRequest^>(WebRequest::Create(URL1));
                HttpWebResponse ^response1 = safe_cast<HttpWebResponse^>(request1->GetResponse());
                StreamReader ^reader1 = gcnew StreamReader(response1->GetResponseStream());
                String ^str1 = reader1->ReadToEnd();
                
    
                //Do login stuff here.
                bool login = false;
                //User Login
                login = true;
    
                if (str == login)
                {
                  MessageBox::Show("You are now login!");
                  //Check if two users are login at the same time.
                  bool checklogin = false;
                }
            }
          }
    }


    The arguments are jumping on the statement of if (str == login). I have got two errors which it is:

    Error: error C2446: '==' : no conversion from 'int' to 'System::String ^'

    Error: error C2040: '==' : 'System::String ^' differs in levels of indirection from 'int'




    I have used the statement as if (str ==login.ToString()), but I did not get the return argument. I have tried to use each different properties, but there are still variable and I still has no return argument. What I am trying to do is to get access to the website, check if the login details is valid then display the messagebox that says "You are now login!".



    Any advice would be much appreciate.

    Thanks,
    Mark

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    611
    What makes you think the answer will be anything different than it was 8 months ago?

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    40
    Quote Originally Posted by adeyblue View Post
    What makes you think the answer will be anything different than it was 8 months ago?
    What the ........ are you talking about?

    I am not using VB.NET which i am now using C++/CLI.

    you are being a noob right here.

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    Print str and take a look at what the website sends you on successful login. I'm pretty sure it's not "true". It will be another html-text, which you will need to parse.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Moved to Windows forum since this is C++/CLI.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. number system conversion
    By princez90 in forum C Programming
    Replies: 7
    Last Post: 04-10-2008, 09:22 PM
  2. Receiving errors C2446 & C2440.
    By gator6688 in forum C++ Programming
    Replies: 3
    Last Post: 10-05-2007, 02:20 PM
  3. std::string conversion
    By MadCow257 in forum C++ Programming
    Replies: 5
    Last Post: 03-13-2006, 06:16 PM
  4. Cannot convert system object to system string?
    By Robert_Sitter in forum Windows Programming
    Replies: 0
    Last Post: 11-18-2005, 01:44 PM
  5. string object to null-terminating string conversion
    By sayz0 in forum C++ Programming
    Replies: 2
    Last Post: 11-05-2001, 11:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21