2022-07-06 16:42:53 +08:00
/*
* <EFBFBD> <EFBFBD> <EFBFBD> ݿ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ӹ <EFBFBD> <EFBFBD> ߺ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ӿ <EFBFBD> ʵ <EFBFBD> <EFBFBD>
*/
2022-07-03 18:22:02 +08:00
# include"DBCUtils.h"
bool getConnection ( std : : string & pwd , _ConnectionPtr & connection ) {
bool isPwdTrue = false ;
_bstr_t strConnect ;
2022-07-04 22:17:38 +08:00
if ( ! pwd . empty ( ) ) { //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> ǿգ <C7BF> ʹ <EFBFBD> <CAB9> SQL Server<65> <72> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֤
2022-07-03 18:22:02 +08:00
try {
std : : string con = " Provider=SQLOLEDB.1;Password= " + pwd + " ; Persist Security Info = True; User ID = sa; Initial Catalog = stuAdminSystem; Data Source = LAPTOP-4DMOD6O5 " ;
strConnect = con . c_str ( ) ;
connection - > Open ( strConnect , " " , " " , NULL ) ;
2022-07-04 22:17:38 +08:00
isPwdTrue = true ; //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȷ<EFBFBD> <C8B7> <EFBFBD> <EFBFBD> <EFBFBD> ӳɹ<D3B3>
2022-07-03 18:22:02 +08:00
wprintf ( L " <EFBFBD> <EFBFBD> ¼<EFBFBD> ɹ<EFBFBD> <EFBFBD> <EFBFBD> \n " ) ;
return true ;
}
catch ( _com_error & err ) {
wprintf ( L " The application throws the error: %s \n " , ( wchar_t * ) err . ErrorMessage ( ) ) ;
wprintf ( L " Description = %s \n " , ( wchar_t * ) err . Description ( ) ) ;
}
2022-07-04 22:17:38 +08:00
if ( ! isPwdTrue ) { //<2F> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> <DCA3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> <DCA3> <EFBFBD> <EFBFBD> <EFBFBD> try<72> <79> ִ<EFBFBD> У <EFBFBD>
2022-07-04 23:39:46 +08:00
wprintf ( L " <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> \n " ) ;
2022-07-03 18:22:02 +08:00
return false ;
}
}
2022-07-04 22:17:38 +08:00
else { //<2F> <> <EFBFBD> <EFBFBD> Ϊ<EFBFBD> գ <EFBFBD> ʹ <EFBFBD> <CAB9> Windows <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֤
2022-07-03 18:22:02 +08:00
try {
strConnect = " Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=stuAdminSystem;Data Source=LAPTOP-4DMOD6O5 " ;
connection - > Open ( strConnect , " " , " " , NULL ) ;
2022-07-04 22:17:38 +08:00
isPwdTrue = true ; //<2F> <> ֤<EFBFBD> ɹ<EFBFBD> <C9B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ӳɹ<D3B3>
2022-07-03 18:22:02 +08:00
wprintf ( L " <EFBFBD> <EFBFBD> ¼<EFBFBD> ɹ<EFBFBD> <EFBFBD> <EFBFBD> \n " ) ;
return true ;
}
catch ( _com_error & err ) {
wprintf ( L " The application throws the error: %s \n " , ( wchar_t * ) err . ErrorMessage ( ) ) ;
wprintf ( L " Description = %s \n " , ( wchar_t * ) err . Description ( ) ) ;
}
2022-07-04 22:17:38 +08:00
if ( ! isPwdTrue ) { //<2F> <> ֤ʧ<D6A4> ܣ<EFBFBD> <DCA3> <EFBFBD> <EFBFBD> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> <DCA3> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʧ<EFBFBD> ܣ<EFBFBD> <DCA3> <EFBFBD> <EFBFBD> <EFBFBD> try<72> <79> ִ<EFBFBD> У <EFBFBD>
2022-07-04 23:39:46 +08:00
wprintf ( L " <EFBFBD> <EFBFBD> ֤ʧ<EFBFBD> ܣ<EFBFBD> \n " ) ;
2022-07-03 18:22:02 +08:00
return false ;
}
}
2022-07-04 22:17:38 +08:00
return false ;
2022-07-03 18:22:02 +08:00
}
void getSqlType ( std : : string & sql , std : : string & comType ) {
2022-07-04 22:17:38 +08:00
size_t len = sql . length ( ) ;
for ( size_t i = 0 ; i < len ; i + + ) { //<2F> <> ȡSQL<51> <4C> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
2022-07-03 18:22:02 +08:00
if ( sql [ i ] ! = ' ' )
comType + = isupper ( sql [ i ] ) ? ( sql [ i ] - 32 ) : sql [ i ] ;
else return ;
}
}