freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "gik" <liauwsiauwlong AT hotmail.com>
- To: freetds AT franklin.oit.unc.edu
- Subject: class CConnect ?
- Date: Fri, 26 Apr 2002 03:19:42 -0400
when I create my own class :
class CConnect {
char user[20] , pass[20] , server[20] ;
DBPROCESS *pDbProc ;
public:
CConnect(char[], char[], char[]) ;
~CConnect() ;
int open_db(char[]) ;
};
CConnect::CConnect(char user[], char pass[], char server[]) {
strcpy( this->user , user ) ;
strcpy( this->pass , pass ) ;
strcpy( this->server , server ) ;
dbinit() ;
}
CConnect::~CConnect() {
dbexit() ;
}
int CConnect::open_db(char database[]) {
LOGINREC *pLogin = dbLogin() ;
DBSETLUSER( pLogin , user ) ;
DBSETLPWD( pLogin , pass ) ;
DBSETLAPP( pLogin , "cmssql" ) ;
pDbProc = dbopen( pLogin , server ) ;
if( pDbProc ) return dbuse( pDbProc , database ) ;
return 0 ;
}
int main () {
int result ;
CConnect connect("wrong_user","pass","server") ;
result = connect.open_db("xxx") ;
if ( result == 0 ) printf("error") ;
}
// my problem if I trying to connect with nonmember database
// It doesn't print error but Segmentation Fault !
// why this happen ? and how to fix it ?
-
class CConnect ?,
gik, 04/26/2002
- <Possible follow-up(s)>
- Re: class CConnect ?, James K . Lowden, 04/26/2002
Archive powered by MHonArc 2.6.24.