当前位置: 首页>>代码示例>>C++>>正文


C++ dberrhandle函数代码示例

本文整理汇总了C++中dberrhandle函数的典型用法代码示例。如果您正苦于以下问题:C++ dberrhandle函数的具体用法?C++ dberrhandle怎么用?C++ dberrhandle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dberrhandle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DBConnect

BOOL DBConnect(char *szServer, char *szUser, char *szPswd)
{
	// Initialize DB-Library
	if ( dbinit() == FAIL ) 
		return FALSE;

	// Install user-supplied error-handling and message-handling
	dberrhandle((EHANDLEFUNC)err_handler);
	dbmsghandle((MHANDLEFUNC)msg_handler);

	// Allocate and init LOGINREC structure used to open a connection to SQL Server
	login = dblogin();
	DBSETLUSER(login, szUser); // "sa"
	DBSETLPWD(login, szPswd);  // ""
	DBSETLAPP(login, "cags_import_bcp");

	// Enable bulk copy for this connection
	BCP_SETL(login, TRUE);
	
	// Get a connection to the database.
	if ((dbproc = dbopen(login, szServer)) == (DBPROCESS *) NULL)   // "cgserver"
	{
		errfile << ERROR_PREFIX << "can't connect to server" << endl;
		return FALSE;
	}

	// Make cags the current database
	if ( dbuse(dbproc, "cags") ==  FAIL )
	{
		errfile << ERROR_PREFIX << "can't make cags current database." << endl;
		return FALSE;
	}
	
	return TRUE;
}
开发者ID:cagsworld,项目名称:Sample,代码行数:35,代码来源:sample.cpp

示例2: sql_init_socket

/*************************************************************************
 *
 *	Function: sql_create_socket
 *
 *	Purpose: Establish connection to the db
 *
 *************************************************************************/
static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
{
	LOGINREC *login;
	rlm_sql_freetds_sock *freetds_sock;
	
	if (!sqlsocket->conn) {
		sqlsocket->conn = (rlm_sql_freetds_sock *)rad_malloc(sizeof(struct rlm_sql_freetds_sock));
		if (!sqlsocket->conn) {
			return -1;
		}
	}
	
	if (dbinit() == FAIL) {
		radlog(L_ERR, "rlm_sql_freetds: Unable to init FreeTDS");
		return -1;		
	}
	
	dbsetversion(DBVERSION_80);
	dberrhandle(err_handler);
	
	// Timeout so that FreeTDS doesn't wait for ever.
	dbsetlogintime((unsigned long)config->query_timeout);
	dbsettime((unsigned long)config->query_timeout);
	
	freetds_sock = sqlsocket->conn;
	memset(freetds_sock, 0, sizeof(*freetds_sock));
	
	DEBUG("rlm_sql_freetds (%s): Starting connect to FreeTDS/MSSQL server", config->xlat_name);
	
	if (!(login = dblogin())) {
		radlog(L_ERR, "rlm_sql_freetds (%s): Unable to allocate login record", config->xlat_name);
		return -1;
	}
	
	DBSETLUSER(login, config->sql_login);
	DBSETLPWD(login, config->sql_password);
	
	if ((freetds_sock->dbproc = dbopen(login, config->sql_server)) == FAIL) {
		radlog(L_ERR, "rlm_sql_freetds (%s): Unable to connect to FreeTDS/MSSQL server %[email protected]%s", 
			   config->xlat_name, config->sql_login, config->sql_server);
		dbloginfree(login);
		return -1;
	}
	
	dbloginfree(login);
	
	if ((dbuse(freetds_sock->dbproc, config->sql_db)) == FAIL) {
		radlog(L_ERR, "rlm_sql_freetds (%s): Unable to select database on FreeTDS/MSSQL server %[email protected]%s:%s", 
			   config->xlat_name, config->sql_login, config->sql_server, config->sql_db);
		return -1;
	}
	
	/* I know this may look strange, but it sets a pointer to
	 the freetds_sock struct so that it can be used within the
	 query_timeout_handler function to be able to timeout properly */
	dbsetinterrupt(freetds_sock->dbproc, query_timeout_handler, query_timeout_handler);
	dbsetuserdata(freetds_sock->dbproc, (BYTE *)freetds_sock);
	
	return 0;
}
开发者ID:FabioPedretti,项目名称:freeradius-server,代码行数:67,代码来源:rlm_sql_freetds.c

示例3: c_syb_make

int c_syb_make (int m_size)
{
  int count;
  
  error_message = (char *) malloc (sizeof (char) * (m_size + ERROR_MESSAGE_SIZE));
  clear_error ();
  max_size = m_size;
  
  if (dbinit () == FAIL)
    {
      return error_number;
      /* exit(ERREXIT); */
    }
  
  dberrhandle ((EHANDLEFUNC)err_handler);
  dbmsghandle ((MHANDLEFUNC)msg_handler);
  
  if (login == NULL)
    {
		login = safe_alloc (dblogin());
		DBSETLCHARSET (login, "utf8");
    }
 
  for (count = 0; count < MAX_DESCRIPTOR; count++)
    {
      descriptor[count] = NULL;
    }
  
  return error_number;
}
开发者ID:jocelyn,项目名称:EiffelStudio,代码行数:30,代码来源:sybase.c

示例4: test

static void
test(const char *type, int give_err)
{
	RETCODE ret;

	query("if object_id('#null') is not NULL drop table #null");

	dberrhandle(ignore_err_handler);
	dbmsghandle(ignore_msg_handler);

	printf("create table #null (n int, c %s NULL)\n", type);
	dbfcmd(dbproc, "create table #null (n int, c %s NULL)", type);
	dbsqlexec(dbproc);

	ret = dbresults(dbproc);

	dberrhandle(syb_err_handler);
	dbmsghandle(syb_msg_handler);

	if (ret != SUCCEED) {
		dbcancel(dbproc);
		if (!give_err)
			return;
		fprintf(stdout, "Was expecting a result set.\n");
		failed = 1;
		return;
	}

	query("insert into #null values(1, '')");
	query("insert into #null values(2, NULL)");
	query("insert into #null values(3, ' ')");
	query("insert into #null values(4, 'foo')");

	use_nullbind = 1;
	test0(1, "");
	test0(2, "aaaaaaaaaaaaaaa");
	test0(3, "");
	test0(4, "foo");

	use_nullbind = 0;
	test0(1, "");
	test0(2, "");
	test0(3, "");
	test0(4, "foo");

	query("drop table #null");
}
开发者ID:mabrand,项目名称:freetds,代码行数:47,代码来源:null2.c

示例5: QTDSDriverPrivate

void QTDSDriver::init()
{
    d = new QTDSDriverPrivate();
    // the following two code-lines will fail compilation on some FreeTDS versions
    // just comment them out if you have FreeTDS (you won't get any errors and warnings then)
    dberrhandle((QERRHANDLE)qTdsErrHandler);
    dbmsghandle((QMSGHANDLE)qTdsMsgHandler);
}
开发者ID:Suneal,项目名称:qt,代码行数:8,代码来源:qsql_tds.cpp

示例6: dberrhandle

QTDSDriver::~QTDSDriver()
{
    dberrhandle(0);
    dbmsghandle(0);
    // dbexit also calls dbclose if necessary
    dbexit();
    delete d;
}
开发者ID:Suneal,项目名称:qt,代码行数:8,代码来源:qsql_tds.cpp

示例7: main

int
main(int argc, char **argv)
{
	LOGINREC *login;

	read_login_info(argc, argv);

	fprintf(stdout, "Starting %s\n", argv[0]);

	dbinit();

	dberrhandle(syb_err_handler);
	dbmsghandle(syb_msg_handler);

	fprintf(stdout, "About to logon\n");

	login = dblogin();
	DBSETLPWD(login, PASSWORD);
	DBSETLUSER(login, USER);
	DBSETLAPP(login, "thread");

	fprintf(stdout, "About to open \"%s\"\n", SERVER);

	dbproc = dbopen(login, SERVER);
	if (!dbproc) {
		fprintf(stderr, "Unable to connect to %s\n", SERVER);
		return 1;
	}

	dbloginfree(login);

	if (strlen(DATABASE))
		dbuse(dbproc, DATABASE);

	test("VARCHAR(10)", 1);
	test("CHAR(10)", 1);
	test("TEXT", 1);

	test("NVARCHAR(10)", 0);
#ifndef DBNTWIN32
	if (dbtds(dbproc) >= DBTDS_7_0)
		test("NTEXT", 0);
#endif

	test("VARCHAR(MAX)", 0);
#ifndef DBNTWIN32
	if (dbtds(dbproc) >= DBTDS_7_0)
		test("NVARCHAR(MAX)", 0);
#endif

	dbexit();

	return failed ? 1 : 0;
}
开发者ID:mabrand,项目名称:freetds,代码行数:54,代码来源:null2.c

示例8: main

int
main(int argc, char *argv[])
{
	LOGINREC *login;
	DBPROCESS *dbproc;
	int ret_code;
	int num_cols;
	int num_res;

	set_malloc_options();

	read_login_info(argc, argv);
	printf("Starting %s\n", argv[0]);
	dbinit();

	dberrhandle(syb_err_handler);
	dbmsghandle(syb_msg_handler);

	printf("About to logon\n");

	login = dblogin();
	DBSETLPWD(login, PASSWORD);
	DBSETLUSER(login, USER);
	DBSETLAPP(login, "t0012");

	dbproc = dbopen(login, SERVER);
	if (strlen(DATABASE)) {
		dbuse(dbproc, DATABASE);
	}
	dbloginfree(login);
	printf("After logon\n");

	/* select */
	sql_cmd(dbproc);
	dbsqlexec(dbproc);

	num_res = 0;
	while ((ret_code = dbresults(dbproc)) == SUCCEED) {
		num_cols = dbnumcols(dbproc);
		printf("Result %d has %d columns\n", num_res, num_cols);
		if (!(num_res % 2) && num_cols)
			set_failed();
		while(dbnextrow(dbproc) != NO_MORE_ROWS) {};
		num_res++;
	}
	if (ret_code == FAIL)
		set_failed();

	dbclose(dbproc);
	dbexit();

	printf("%s %s\n", __FILE__, (failed ? "failed!" : "OK"));
	return failed ? 1 : 0;
}
开发者ID:FreeTDS,项目名称:freetds,代码行数:54,代码来源:empty_rowsets.c

示例9: dbd_freetds_init

static void dbd_freetds_init(apr_pool_t *pool)
{
    int rv = regcomp(&dbd_freetds_find_arg,
                     "%(\\{[^}]*\\})?([0-9]*)[A-Za-z]", REG_EXTENDED);
    if (rv != 0) {
        char errmsg[256];
        regerror(rv, &dbd_freetds_find_arg, errmsg, 256);
        fprintf(stderr, "regcomp failed: %s\n", errmsg);
    }
    dbinit();
    dberrhandle(freetds_err_handler);
    apr_pool_cleanup_register(pool, NULL, freetds_term, apr_pool_cleanup_null);
}
开发者ID:cmjonze,项目名称:apr,代码行数:13,代码来源:apr_dbd_freetds.c

示例10: rb_tinytds_connect

static VALUE rb_tinytds_connect(VALUE self, VALUE opts) {
    /* Parsing options hash to local vars. */
    VALUE user, pass, dataserver, database, app, version, ltimeout, timeout, charset;
    user = rb_hash_aref(opts, sym_username);
    pass = rb_hash_aref(opts, sym_password);
    dataserver = rb_hash_aref(opts, sym_dataserver);
    database = rb_hash_aref(opts, sym_database);
    app = rb_hash_aref(opts, sym_appname);
    version = rb_hash_aref(opts, sym_tds_version);
    ltimeout = rb_hash_aref(opts, sym_login_timeout);
    timeout = rb_hash_aref(opts, sym_timeout);
    charset = rb_hash_aref(opts, sym_encoding);
    /* Dealing with options. */
    if (dbinit() == FAIL) {
        rb_raise(cTinyTdsError, "failed dbinit() function");
        return self;
    }
    dberrhandle(tinytds_err_handler);
    dbmsghandle(tinytds_msg_handler);
    GET_CLIENT_WRAPPER(self);
    cwrap->login = dblogin();
    if (!NIL_P(user))
        dbsetluser(cwrap->login, StringValuePtr(user));
    if (!NIL_P(pass))
        dbsetlpwd(cwrap->login, StringValuePtr(pass));
    if (!NIL_P(app))
        dbsetlapp(cwrap->login, StringValuePtr(app));
    if (!NIL_P(version))
        dbsetlversion(cwrap->login, NUM2INT(version));
    if (!NIL_P(ltimeout))
        dbsetlogintime(NUM2INT(ltimeout));
    if (!NIL_P(timeout))
        dbsettime(NUM2INT(timeout));
    if (!NIL_P(charset))
        DBSETLCHARSET(cwrap->login, StringValuePtr(charset));
    cwrap->client = dbopen(cwrap->login, StringValuePtr(dataserver));
    if (cwrap->client) {
        cwrap->closed = 0;
        cwrap->charset = charset;
        dbsetuserdata(cwrap->client, (BYTE*)cwrap->userdata);
        cwrap->userdata->closed = 0;
        if (!NIL_P(database))
            dbuse(cwrap->client, StringValuePtr(database));
#ifdef HAVE_RUBY_ENCODING_H
        VALUE transposed_encoding = rb_funcall(cTinyTdsClient, intern_transpose_iconv_encoding, 1, charset);
        cwrap->encoding = rb_enc_find(StringValuePtr(transposed_encoding));
#endif
    }
    return self;
}
开发者ID:filipeamoreira,项目名称:tiny_tds,代码行数:50,代码来源:client.c

示例11: main

int main(void)
{

  /* initialize db library */
  if (dbinit() == FAIL)
    return 0;

  /* set message and error handler routines */
  dberrhandle((EHANDLEFUNC)err_handler);
  dbmsghandle((MHANDLEFUNC)msg_handler);

  /* create login, user and pw are stored in  sybdbex.h */
  login = dblogin();
  DBSETLUSER(login, USER);
  DBSETLPWD(login, PASSWORD);
  DBSETLAPP(login, "store_beispiel");

  /* login to server */
  dbproc = dbopen(login, "syb150");
  dbuse(dbproc, "ma11s61406"); 

  while(1)
  {
    get_berufe();

    printf("beruf?\n");
    gets(answer);
    
    if(strcmp(answer, "")==0)
      continue;
  while(1)
  {
    get_mitarbeiter(answer);

    printf("mitnr?\n");
    gets(answer);

    if(strcmp(answer, "")==0)
      break;
    get_all(answer);
    break;
  }
  }

    /* dbexit(STDEXIT); */
    dbexit();
    exit(STDEXIT);
}
开发者ID:mYstar,项目名称:DBTMA,代码行数:48,代码来源:prakt1.c

示例12: dberrhandle

void Connector::init(string host, string port, string user, string password, string db)
{

#ifdef MSSQL
	login_rec = NULL;
	conn_ptr = NULL;
	dberrhandle (err_handler);
	dbmsghandle (msg_handler);

	conn_status = false;
	cout << "init db connectors.. " << endl;
	init_db_connectors();
	if(conn_status){
		set_login_struct(user , password);
		cout << "added login credentials to struct.. " << endl;
		if (conn_status){
			cout << "connecting to db..." << db << endl;
			connect_to_db(host , port);
			if (conn_status){
				choose_db(db);
			} else {
				cout << "geterror: " << geterror() << endl;
			}
		} else {
			cout << "geterror: " << geterror() << endl;
		}
	} else {
		cout << "geterror: " << geterror() << endl;
	}
#endif
#ifdef WATCHLIST_MYSQL
	cout << "Connecting to mysql db.. "  << endl;
	conn_status = true;
	mysql_init(&mysqlID);
	mysql_options(&mysqlID, MYSQL_OPT_RECONNECT, (char *)&conn_status);
	mysql_real_connect(&mysqlID, host.c_str(), user.c_str(), password.c_str(), db.c_str(), 0, NULL, CLIENT_COMPRESS | CLIENT_MULTI_RESULTS | CLIENT_MULTI_STATEMENTS);

#endif

}
开发者ID:20083017,项目名称:mysql_connector,代码行数:40,代码来源:Connector.cpp

示例13: init_db

int init_db(void){
	/* initialize db library */
	if (dbinit() == FAIL)
		return 0;

	/* set message and error handler routines */
	dberrhandle((EHANDLEFUNC)err_handler);
	dbmsghandle((MHANDLEFUNC)msg_handler);

	/* create login, user and pw are stored in  sybdbex.h */
	login = dblogin();
	DBSETLUSER(login, USER);
	DBSETLPWD(login, PASSWORD);
	DBSETLAPP(login, "berufe");

	/* login to server */
	dbproc = dbopen(login, "syb150");
	dbproc_insert = dbopen(login, "syb150");
	dbuse(dbproc, "ma11s67778");
	dbuse(dbproc_insert, "ma11s67778");

}
开发者ID:mYstar,项目名称:DBTMA,代码行数:22,代码来源:prakt1.c

示例14: putenv

DBPROCESS	*ConnectDB()
{
	DBPROCESS   *dbproc;
	LOGINREC    *login;

	putenv("TDSVER=42");
	dbinit();
	dberrhandle(syb_err_handler);
	dbmsghandle(syb_msg_handler);
	login = dblogin();
	DBSETLPWD(login, "yjkim");
	DBSETLUSER(login, "tim_yjkim");
	DBSETLAPP(login, "Sync");
	DBSETLHOST(login, "auth01");

	dbproc = dbopen(login, "webDB");
	if(!dbproc) {
		fprintf(stderr, "Unable to Connect to %s", "webDB");
		exit(-1);
	}

	dbloginfree(login);
	return	dbproc;
}
开发者ID:k2b3d,项目名称:authsrc,代码行数:24,代码来源:DBProcess.cpp

示例15: main

int
main(int argc, char **argv)
{
	LOGINREC *login;
	DBPROCESS *dbproc;
	int i;
	char teststr[1024];
	DBINT testint;
	DBVARYBIN  testvbin;
	DBVARYCHAR testvstr;
	int failed = 0;
	int expected_error;

	set_malloc_options();

	read_login_info(argc, argv);

	fprintf(stdout, "Starting %s\n", argv[0]);

	dbinit();

	dberrhandle(syb_err_handler);
	dbmsghandle(syb_msg_handler);

	fprintf(stdout, "About to logon\n");

	login = dblogin();
	DBSETLPWD(login, PASSWORD);
	DBSETLUSER(login, USER);
	DBSETLAPP(login, "t0007");

	fprintf(stdout, "About to open\n");

	dbproc = dbopen(login, SERVER);
	if (strlen(DATABASE))
		dbuse(dbproc, DATABASE);
	dbloginfree(login);

	create_tables(dbproc, 10);

	if (!start_query(dbproc)) {
		fprintf(stderr, "%s:%d: start_query failed\n", __FILE__, __LINE__);
		failed = 1;
	}

	dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint);
	dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr);

	for (i = 1; i <= 2; i++) {
		char expected[1024];

		sprintf(expected, "row %07d", i);

		if (i % 5 == 0) {
			dbclrbuf(dbproc, 5);
		}

		testint = -1;
		strcpy(teststr, "bogus");

		if (REG_ROW != dbnextrow(dbproc)) {
			fprintf(stderr, "Failed.  Expected a row\n");
			abort();
		}
		if (testint != i) {
			fprintf(stderr, "Failed.  Expected i to be %d, was %d\n", i, (int) testint);
			abort();
		}
		if (0 != strncmp(teststr, expected, strlen(expected))) {
			fprintf(stdout, "Failed.  Expected s to be |%s|, was |%s|\n", expected, teststr);
			abort();
		}
		printf("Read a row of data -> %d %s\n", (int) testint, teststr);
	}


	fprintf(stdout, "second select.  Should fail.\n");

	expected_error = 20019;
	dbsetuserdata(dbproc, (BYTE*) &expected_error);

	if (start_query(dbproc)) {
		fprintf(stderr, "%s:%d: start_query should have failed but didn't\n", __FILE__, __LINE__);
		failed = 1;
	}

	dbcancel(dbproc);
	
	/* 
	 * Test Binary binding
	 */
	if (!start_query(dbproc)) {
		fprintf(stderr, "%s:%d: start_query failed\n", __FILE__, __LINE__);
		failed = 1;
	}

	dbbind(dbproc, 1, VARYBINBIND, sizeof(testvbin), (BYTE *) &testvbin);
	dbbind(dbproc, 2, VARYCHARBIND, sizeof(testvstr), (BYTE *) &testvstr);
	dbbind(dbproc, 3, BINARYBIND, sizeof(testint), (BYTE *) &testint);

//.........这里部分代码省略.........
开发者ID:DavidRueter,项目名称:freetds,代码行数:101,代码来源:t0007.c


注:本文中的dberrhandle函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。