Home > Software engineering >  SQL database built, using vc 6.0 did interface also run a success, how to connect. Hope the great go
SQL database built, using vc 6.0 did interface also run a success, how to connect. Hope the great go

Time:09-29

SQL database is built, the use of vc + + 6.0 in the interface also run a success, how to connect, first learn to hope the great god give directions

CodePudding user response:

The SQL official document, there are detailed examples of
Put on mysql based registration and login

Int CConnectDB: : ConnectDB ()
{
If (mysql_init (& amp; Mysql_rcs)==NULL)
return 1;

if (! Mysql_real_connect (& amp; Mysql_rcs, "192.168.1.154", "root", "791745", "TPMS", 3306, NULL, 0))
{
AfxMessageBox (mysql_error (& amp; Mysql_rcs));
return -1;
}
return 0;
}

Void CConnectDB: : disconnectDB ()
{
Mysql_close (& amp; Mysql_rcs);
}

Int CConnectDB: : NameSearch (LPCSTR szUser, LPCSTR szPass)
{
MYSQL_RES * result;
Result=NULL;
Char querystr [MAX_SQL_QUERY_LEN];
Memset (querystr, 0, MAX_SQL_QUERY_LEN);
Sprintf (querystr, "SELECT the UserName FROM the UserName WHERE UserName='% s'", szUser);
Mysql_query (& amp; Mysql_rcs, "set names' GBK '");
if (! Mysql_query (& amp; Mysql_rcs querystr))
{
Result=mysql_store_result (& amp; Mysql_rcs);
If (result - & gt; Row_count)
{
Memset (querystr, 0, MAX_SQL_QUERY_LEN);
Sprintf (querystr, "SELECT the UserName FROM the UserName WHERE PassWords='% s'", szPass);
if(! Mysql_query (& amp; Mysql_rcs querystr))
{
Result=mysql_store_result (& amp; Mysql_rcs);
If (result - & gt; Row_count)
{
The mysql_free_result (result);
return 0;
}
The else
{
return -1;
}
}
The else
{
Int nError=mysql_errno (& amp; Mysql_rcs);
The return - 2;
}
}
The else
{
Int nError=mysql_errno (& amp; Mysql_rcs);
The mysql_free_result (result);
The return - 3;
}
}
The else
The return - 4;
}

Int CConnectDB: : Registr (LPCSTR szUser, LPCSTR szPass)
{
MYSQL_RES * result;
Result=NULL;
Char querystr [MAX_SQL_QUERY_LEN];
Memset (querystr, 0, MAX_SQL_QUERY_LEN);
Sprintf (querystr, "INSERT INTO the username (username, PassWords) VALUES (' % s', '% s')", szUser, szPass);
Mysql_query (& amp; Mysql_rcs, "set names' GBK '");
if (! Mysql_query (& amp; Mysql_rcs querystr))
{
Result=mysql_store_result (& amp; Mysql_rcs);
if(! The result)
{
//mysql_free_result (result);
Result=NULL;
return 0;
}
The else
{
Int nError=mysql_errno (& amp; Mysql_rcs);
return -1;
}
}
The else
{
Int nError=mysql_errno (& amp; Mysql_rcs);
The return - 2;
}
}

CodePudding user response:

Replication is too messy, posted a PIC

CodePudding user response:

Ttttttttttttttttt

CodePudding user response:

Ado help documents

CodePudding user response:

I guess the original poster with VC with database is essentially a
So, can go to the MSDN ADO document search

CodePudding user response:

http://www.cnblogs.com/nktblog/articles/2770706.html
  • Related