Hi, i'm doing a small program that communicates with my first SQL Server, but I'm having some troubles with the C++ (I'm usued to C only, and use it for developing microcontrolers firmwares).
What Im trying to do here is it:
Write the USER and PASSWORD in a form, then send the values to my "database class", it will evaluate the user/pass and login in the mysql server and the program say "connection OK".
I've done it all EXCEPT the form thing, here is the problem I'm having:
I extract the string from the "userBox->Text" to another string and I pass that string to my class ( mySqlDatabase(char *serverName, string& user, string& password, char *dbName) ) but it gives out two diferent erros which seens to have no relation (and I'm quite newbie in C++ so both are misteries to me).
1>e:\users\user\documents\projetos\testes\project1\test form db last\test form db last\mydb.h(29) : error C2061: syntax error : identifier 'string'
1>e:\users\user\documents\projetos\testes\project1\test form db last\test form db last\Form1.h(153) : error C2661: 'mySqlDatabase::mySqlDatabase' : no overloaded function takes 4 arguments
here the codes that are giving me the most headache.
private: System::Void connectButton_Click(System::Object^ sender, System::EventArgs^ e) {
String^ user = userBox->Text;
String^ pwd = passBox->Text;
mySqlDatabase conexao1("localhost", user, pwd, "cpp_data");
if(conexao1.connection(1)){
textBox1->Text = L"Connection OK";
}
Delete conexao1; //test purposes
}
the mySqlDatabase class
class mySqlDatabase{
private:
char TABLE_OF_INTEREST[25];
char SERVER_NAME[25];
char DB_USER[25];
char DB_USERPASS[25];
char DB_NAME[25];
public:
mySqlDatabase(){}
// /*
mySqlDatabase(char *serverName, string& user, string& pwd, char *dbName){
strcpy( TABLE_OF_INTEREST, "users");
strcpy( SERVER_NAME, "localhost");
strcpy( DB_USER, user);
strcpy( DB_USERPASS, pwd);
strcpy( DB_NAME, "cpp_data");
}
int connection(int arg){
MYSQL *hnd=NULL; // mysql connection handle
const char *sinf=NULL; // mysql server information
hnd = mysql_init(NULL);
if (NULL == mysql_real_connect(hnd,SERVER_NAME,DB_USER,DB_USERPASS,DB_NAME,0,NULL,0)){
<...>
}