First thank you all for your reply.
And i am using Windows ...

I know in C# is more easy but i need C++.

Ill try the method with sockets and ... Thines, can you give me an example of WebClient^ ?
Thanks.

EDIT : My project is a Windows Form type.

This can be done more easly with the webBrowser1 from Tools ?

Edited 4 Years Ago by zekstein: n/a

>>EDIT : My project is a Windows Form type.

That is not c++ -- its CLI/C++ which is slightly different language

>>This can be done more easly with the webBrowser1 from Tools ?

Probably.

Edited 4 Years Ago by Ancient Dragon: n/a

First thank you all for your reply.
EDIT : My project is a Windows Form type./QUOTE]

What are you going to DO with the contents of the web page when you get it?

In final i found how to take the contents of the page like that :

private: System::Void webBrowser1_Navigated(System::Object^  sender, System::Windows::Forms::WebBrowserNavigatedEventArgs^  e) {
             if( this->webBrowser1->DocumentText->ToString() != "err" )
             {

                 // here i need something like that :
                                // this->webBrowser1->DocumentText->ToString() is
                                 // blahtext|blahtext2|blahtext3
                                 // i want to break that string into 3 another like :

                                 this->webBrowser1->DocumentText->ToString() 
                                     to
                                 blahtext
                                 blahtext2
                                 blahtext3

                                 this->label6->Text = Variablethatcontains blahtext
 this->label7->Text = Variablethatcontains blahtext2
this->label8->Text = Variablethatcontains blahtext3

             }
         }

Edited 3 Years Ago by Dani: Formatting fixed

I'm still confused.
Can you just use this->webBrowser1->DocumentText->ToString()->Split( /*parameters go here*/) ?
to convert that text into an array?

I still need to ask, are you just attempting to get some text from a page or do you actually need to start a browser object?

Anyway i made it but ....
I need to retrieve data from a server and that solution with read web page isn't good ...
I need MYSQL.
How to implement mysql with C++ ?
I don't think is an default include ...

If you have not already downloaded the connector (for .net), you will need to get it:
http://www.mysql.com/downloads/connector/net/

Once you get that installed, you can add a reference to the MySql.Data DLL entry and add "using namespace MySql:: Data::MySqlClient;" to the code that will use it.

Edited 4 Years Ago by thines01: formatting

Comments
Very very helpfull

And if i build my application, and i publish it .. i need to put the mysql dll near it ?

Ex APP.exe
mydll.exe

If yes, is possible to embed dll in app ? I want One file for my app.

Later Reply : How to use that Mysql Connector ? Exists any tutorial or don't know im very 'newb' at C++ and MYSQL .............

Edited 4 Years Ago by zekstein: n/a

Yes i tried but when i try to compile im getting a nasty error :

Cannot find : boost/system.hpe
Don't know exactly the error ( i closed visual studio ).

LE : LotOfLaugh : When i reopened visual studio and added again the connector the error dissapeared.

As i seen on Google ....
The examples are like that :

/* MySQL Connector/C++ specific headers */
#include <driver.h>
#include <connection.h>
#include <statement.h>
#include <prepared_statement.h>
#include <resultset.h>
#include <metadata.h>
#include <resultset_metadata.h>
#include <exception.h>
#include <warning.h>

But i don't have that... I have.. using namespace MySql:: Data::MySqlClient;

Edited 4 Years Ago by zekstein: n/a

Don't include those headers.


There is documentation on the site.

...but here is a code snippet assuming you have a database table named "SOME_TABLE" that has a column called "NAME":

#include "stdafx.h"

using namespace System;
using namespace System::Collections::Generic;
using namespace System::IO;//assuming you still need this for the other part
using namespace System::Net; //assuming you still need this for the other part
using namespace MySql::Data::MySqlClient;

bool GetListFromDb(List<String^>^ lst_strNames, String^% strError)
{
   bool blnRetVal = true;

   try
   {
      MySqlConnectionStringBuilder^ csb = gcnew MySqlConnectionStringBuilder();
      csb->Server = "{server address goes here}";
      csb->Database = "{database name goes here}";
      csb->UserID = "{user id goes here}";
      csb->Password = "{password goes here}";

      MySqlConnection^ conn = gcnew MySqlConnection(csb->ToString());
      String^ strSQL = "SELECT NAME from SOME_TABLE";
      MySqlDataReader^ rdr = (gcnew MySqlCommand(strSQL, conn))->ExecuteReader();
      while(rdr->Read())
      {
         lst_strNames->Add(rdr["NAME"]->ToString()->Trim());
      }
      rdr->Close();
      conn->Close();
   }
   catch(Exception^ exc)
   {
      blnRetVal = false;
      strError = exc->Message;
   }

   return blnRetVal;
}

...and it can be called like this:

String^ strError = "";
    List<String^>^ lst_strNames = gcnew List<String^>();

    if(!GetListFromDb(lst_strNames, strError))
    {
       System::Diagnostics::Debug::WriteLine("Could not load list: " + strError);
       return -1;
    }

Edited 4 Years Ago by thines01: clarity

Tried

String^ strError = "";
    List<String^>^ lst_strNames = gcnew List<String^>();

			 MySqlConnectionStringBuilder^ csb = gcnew MySqlConnectionStringBuilder();
      csb->Server = "localhost";
      csb->Database = "dumi";
      csb->UserID = "dumi";
      csb->Password = "dumi";
 
      MySqlConnection^ conn = gcnew MySqlConnection(csb->ToString());
      String^ strSQL = "SELECT * from servers";
      MySqlDataReader^ rdr = (gcnew MySqlCommand(strSQL, conn))->ExecuteReader();
      while(rdr->Read())
      {
         lst_strNames->Add(rdr["id"]->ToString()->Trim());
      }
      rdr->Close();
      conn->Close();

Getting

1>c:\users\adrian\desktop\dhlds2\dhlds2\Form1.h(668): error C2065: 'List' : undeclared identifier
1>c:\users\adrian\desktop\dhlds2\dhlds2\Form1.h(668): error C2275: 'System::String' : illegal use of this type as an expression
1>          c:\program files\reference assemblies\microsoft\framework\.netframework\v4.0\mscorlib.dll : see declaration of 'System::String'
1>c:\users\adrian\desktop\dhlds2\dhlds2\Form1.h(668): error C2059: syntax error : '>'
1>c:\users\adrian\desktop\dhlds2\dhlds2\Form1.h(681): error C2065: 'lst_strNames' : undeclared identifier
1>c:\users\adrian\desktop\dhlds2\dhlds2\Form1.h(681): error C2227: left of '->Add' must point to class/struct/union/generic type

Now is working thank you soo much !

Two last things :

String^ strError = "";
List<String^>^ lst_strNames = gcnew List<String^>();

if(!GetListFromDb(lst_strNames, strError))
{
this->textBox4->Text = lst_strNames; // how to do that ?
}

And the 2nd ... that connector needs an .dll or something present near the application ? If yes ... how to 'hide it' inside the application ?

What you're asking is how to convert a list of Strings to a single String.

I would do it like this:

using namespace System::Linq;

...

this->textBox4->Text = 
       String::Join("\n",
         Enumerable::ToArray<String^>(lst_strNames));

Something not working ...

I have the Mysql SERVER ONLINE ....
The code is :

bool GetListFromDb(List<String^>^ lst_strNames, String^% strError)
{
   bool blnRetVal = true;

   try
   {
      MySqlConnectionStringBuilder^ csb = gcnew MySqlConnectionStringBuilder();
      csb->Server = "localhost";
      csb->Database = "dumi";
      csb->UserID = "dumi";
      csb->Password = "dumi";

      MySqlConnection^ conn = gcnew MySqlConnection(csb->ToString());
      String^ strSQL = "SELECT * FROM `bla` WHERE (`ident` = '1' );";
      MySqlDataReader^ rdr = (gcnew MySqlCommand(strSQL, conn))->ExecuteReader();
      while(rdr->Read())
      {
         lst_strNames->Add(rdr["blah2"]->ToString()->Trim());
      }
      rdr->Close();
      conn->Close();
   }
   catch(Exception^ exc)
   {
      blnRetVal = false;
   }

   return blnRetVal;
}

2nd

String^ strError = "test";
    List<String^>^ lst_strNames = gcnew List<String^>();
 
    if(GetListFromDb(lst_strNames, strError))
    {
      this->textBox1->Text = String::Join("\n", Enumerable::ToArray<String^>(lst_strNames));
      // return -1;
    }
	else
	{
		this->textBox1->Text = strError;
	}

The mysql table is ok because with php it works ...

and when i run the code ...
the textbox is changeing into 'test'
What's wrong ?

Edited 4 Years Ago by zekstein: n/a

You removed the exclamation point from the if statement:

if(!GetListFromDb(lst_strNames, strError))

Now, the textbox has no content ...
That can be from the mysql query syntax ? ( that 'blah2' is VARCHAR with 500 length )

You can remove those accent marks from you db elements.

When you step through this in the debugger, is the line of code executed that moves the data into the List?

while(rdr->Read())
      {
          this->textBox3->Text = "debuged"; //notexecuted
         lst_strNames->Add(rdr["host"]->ToString()-> Trim());
      }

Edited 3 Years Ago by Dani: Formatting fixed

...then the SELECT is not working.
There is no data matching the criteria.
- Could be the column you're pulling
- Could be the extra decoration inside your SQL


MY BAD

...forgot to call Open on the database connection'conn->Open(); //before you call Read()

Edited 4 Years Ago by thines01: n/a

MySqlConnectionStringBuilder^ csb = gcnew MySqlConnectionStringBuilder();
      csb->Server = "localhost";
      csb->Database = "dumi";
      csb->UserID = "dumi";
      csb->Password = "dumi";
		
      MySqlConnection^ conn = gcnew MySqlConnection(csb->ToString());
        	  conn->Open();
	  String^ strSQL = "SELECT * FROM `blah` WHERE (`ident` = '1' );";
      MySqlDataReader^ rdr = (gcnew MySqlCommand(strSQL, conn))->ExecuteReader();
	  
	  while(rdr->Read())
      {
		  this->textBox3->Text = "debuged";
         lst_strNames->Add(rdr["blah2"]->ToString()-> Trim());
      }
      rdr->Close();
      conn->Close();

Going into

String^ strError = "";
    List<String^>^ lst_strNames = gcnew List<String^>();
 
    if(!GetListFromDb(lst_strNames, strError))
    {
      this->textBox1->Text = String::Join("\n", Enumerable::ToArray<String^>(lst_strNames));
      // return -1;
    }
	else
	{
		[B]this->textBox1->Text = "ERR";[/B]
	}

The function reports its errors in strError. You can use that to see what actually went wrong.
...and that else you added is purely cosmetic.

Edited 4 Years Ago by thines01: n/a

Then there is no error.

...which should mean something is NOW in the List, right?

Edited 4 Years Ago by thines01: n/a

This question has already been answered. Start a new discussion instead.