CodePudding user response:
Access database using ado linkBaidu method!
CodePudding user response:
1. Do first login dialog, the main dialog to add the following code to initialize:1.1 the resources needed to initialize the code dialog,
1.2 used to initialize the database environment, connect to the database,
2. Add the following code in the login dialog, such as user name and password stored in the database, by comparing the data in the data to confirm the login
I ever did was give a login box for your reference, the code is as follows:
The UpdateData (true);
Static int input_Qty=0;
Int perm_temp;
If (m_Username. IsEmpty () | | m_Password. IsEmpty ())
{
MessageBox (" note: the user name or password can't be empty ");
}
Input_Qty + +;//calculate number of login
Cstrings SQLstr SQLtemp;//database query
//create instances, you connect you record set
TheApp. M_pRecordset. CreateInstance (_uuidof (you));
//build SQL query string
SQLstr. The Format (" select * from tb_User_info where User_name='% s' and Password=' % s' ", m_Username, m_Password);
//query you record sets, and return you the record pointer
TheApp. M_pRecordset=theApp. M_pConnection - & gt; Execute (_bstr_t (SQLstr), NULL, adCmdText);
//whether you record set a pointer to the footer, is: indicates that the login information matching failure; No: indicates that the login information matching success;
if(! TheApp. M_pRecordset - & gt; AdoEOF)//
{
//save user name
M_user=m_Username;
The Username=m_Username;
//get the user login permissions
_variant_t var=(_variant_t) theApp. M_pRecordset - & gt; GetCollect (" Permissions ");
//change _variant_t to int
Var. ChangeType (VT_I4);
Perm_temp=var. LVal;//user permissions after converted to int, passed to the temporary variable
Perm=perm_temp;
CDialog: : OnOK ();//close the login box, enter the main dialog
}
The else
{
CProduct_ManageSystemDlg DLG.
If (3==input_Qty)
{
MessageBox (" entered an incorrect password three times!" );
CDialog: : OnCancel ();//lose the wrong password three times in a row, close the login window.
//DLG. OnCancel;
//DLG. CloseWindow ();
}
The else
{
MessageBox (" username or password is not correct!" );
M_Username="";
M_Password="";
The UpdateData (false);
}
}
CodePudding user response:
Add my qq, help you,CodePudding user response:
The login screen approach:http://blog.csdn.net/qinde025/article/details/7914986
Database you didn't say anything, I also can't help you a kid