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


C++ DBSETLUSER函数代码示例

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


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

示例1: save_pid_to_db

int save_pid_to_db(int id,char* pd)
{
   char szUsername[32] = "sa"; 
   char szPassword[32]= "1qazxsw2*";
   char szDBName[32] = "ids_db";
   char szServer[32] = "10.2.10.201";
   char   sqlquery[1024]={0};
   snprintf(sqlquery,1024,"update ids_policy_event set pid='%s' where id='%d'",pd,id);
   dbinit();
   LOGINREC *loginrec = dblogin();
   DBSETLUSER(loginrec, szUsername);
   DBSETLPWD(loginrec, szPassword);
   DBPROCESS *dbprocess = dbopen(loginrec, szServer);
   if(dbprocess == FAIL)
   {
    LOG_INFO(" Conect MS SQL SERVER fail       ");
    return -1;
   }
   if(dbuse(dbprocess, szDBName) == FAIL)
   {
    LOG_INFO(" Open database name fail");
    return -1;
   }
   dbcmd(dbprocess,sqlquery);
   if(dbsqlexec(dbprocess) == FAIL)
   {
    LOG_INFO("task.cpp dbsqlexec  error!!!");
   }
  dbclose(dbprocess);
  return 0; 
}
开发者ID:crspecter,项目名称:multiprocess_nmap,代码行数:31,代码来源:task.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: 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

示例4: db_connect

RETCODE db_connect(const char * user,const char * passwd, const char* serv_name,const char * db_name,DBPROCESS **db_proc)
{
	LOGINREC *login;
	DBPROCESS *dbproc;
	RETCODE erc=-1;
	if(dbinit()==FAIL)
		{
		fprintf(stderr,"%s:%d: dbinit() failed\n", __func__, __LINE__);
		return erc;
		}
	if((login=dblogin())==NULL)
		{
		
		fprintf(stderr, "%s:%d: unable to allocate login structure\n", __func__, __LINE__);
		return erc;
		}
	DBSETLUSER(login,user);
	DBSETLPWD(login,passwd);
	if((dbproc=dbopen(login,serv_name))==NULL)
		{
		 fprintf(stderr, "%s:%d: unable to connect to %s as %s\n", __func__, __LINE__,serv_name, user);
		return erc;
		}
	if(db_name && ((erc=dbuse(dbproc,db_name))==FAIL))
		{
		
		fprintf(stderr, "%s:%d: unable to use to database %s\n", __func__, __LINE__, db_name);
		return erc;
		}
	*db_proc=dbproc;
	return erc;
}
开发者ID:doorhinges0,项目名称:doorhinges00,代码行数:32,代码来源:db_connect.c

示例5: dbinit

void sql_server_operator::start_up()
{

	//初始化
   	dbinit();
   //连接数据库
   	loginrec = dblogin();

	DBSETLUSER(loginrec, user_name.c_str());
	DBSETLPWD(loginrec, password.c_str());
	dbprocess = dbopen(loginrec, server_host.c_str());
	if(dbprocess == FAIL)
	{
	 	throw std::runtime_error("sqlserver val_ptr new failed");
	    
	}
	if(dbuse(dbprocess, dbname.c_str()) == FAIL)
	{
	 	throw std::runtime_error("sqlserver val_ptr new failed");
	    
	}

   
	pthread_create(&tid, NULL, _thread_t<sql_server_operator, &sql_server_operator::_Run>, this);
	pthread_detach(tid);
	
}
开发者ID:crspecter,项目名称:prober,代码行数:27,代码来源:sqlserver.cpp

示例6: Login

    // TODO Rewrite login so that it does not use an object for a parameter. +callback?
    // assumes {userId: 'user name', password: 'password', server: 'server', database: 'database' }
    // returns a database reference
    static v8::Handle<Value> Login(const Arguments& args) {
      v8::HandleScope scope;
      LOGINREC *login;
      DBPROCESS *dbconn;

      REQ_OBJ_ARG(0, connArgs);

      /* Allocate a login params structure */
      if ((login = dblogin()) == FAIL) {
        return v8::ThrowException(v8::Exception::Error(v8::String::New("FreeTDS cannot initialize dblogin() structure.")));
      }

      // fill out the login params
      v8::Local<v8::String> userIdKey = v8::String::New("userId");
      if(connArgs->Has(userIdKey)){
        String::AsciiValue userId(connArgs->Get(userIdKey));
        DBSETLUSER(login, *userId);
      }

      v8::Local<v8::String> passwordKey = v8::String::New("password");
      if(connArgs->Has(passwordKey)){
        String::AsciiValue password(connArgs->Get(passwordKey));
        DBSETLPWD(login, *password);
      }

      // set the application name to node-freetds to help with profiling etc
      DBSETLAPP(login, "node-freetds");      

      v8::Local<v8::String> serverKey = v8::String::New("server");
      if(!connArgs->Has(serverKey)){
        dbloginfree(login);
        return v8::ThrowException(v8::Exception::Error(v8::String::New("The server name was not provided")));
      }
      String::AsciiValue serverName(connArgs->Get(serverKey));
      
      /* Now connect to the DB Server */
      if ((dbconn = dbopen(login, *serverName)) == NULL) {
        dbloginfree(login);
        return v8::ThrowException(v8::Exception::Error(v8::String::New("FreeTDS cannot initialize dblogin() structure.")));
      }

      v8::Local<v8::String> dbKey = v8::String::New("database");
      if(connArgs->Has(dbKey)){
        String::AsciiValue database(connArgs->Get(dbKey));
        /* Now switch to the correct database */
        if ((dbuse(dbconn, *database)) == FAIL) {
          dbloginfree(login);
          return v8::ThrowException(v8::Exception::Error(v8::String::New("FreeTDS could not switch to the database")));
        }
      }

      // free the login struct because we don't need it anymore
      dbloginfree(login);

      // wrap the dbconn so that we can persist it from the JS side
      return v8::External::Wrap(dbconn);
    }
开发者ID:18liuyuan,项目名称:node-freetds,代码行数:60,代码来源:node_freetds.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: main

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

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

	dbinit();

	printf("About to logon\n");

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

	printf("About to open\n");

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

	printf("Dropping table\n");
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}

	printf("creating table\n");
	sql_cmd(dbproc);
	dbsqlexec(dbproc);
	while (dbresults(dbproc) != NO_MORE_RESULTS) {
		/* nop */
	}

	printf("insert\n");

	insert_row(dbproc);
	insert_row(dbproc);
	insert_row(dbproc);

	failed = select_rows(dbproc, STRINGBIND);

	dbexit();

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

示例10: ngx_dbd_freetds_set_auth

static ngx_int_t
ngx_dbd_freetds_set_auth(ngx_dbd_t *dbd, u_char *user, u_char *passwd)
{
    ngx_dbd_freetds_ctx_t  *ctx;

    ngx_log_debug0(NGX_LOG_DEBUG_MYSQL, dbd->log, 0, "dbd freetds set auth");

    ctx = dbd->ctx;

    DBSETLUSER(ctx->login, (LPCSTR) user);
    DBSETLPWD(ctx->login, (LPCSTR) passwd);

    return NGX_OK;
}
开发者ID:chenbk85,项目名称:ngx_dbd_module,代码行数:14,代码来源:ngx_dbd_freetds.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: thread_test

static void *
thread_test(void * arg)
{
	int i;
	int num = ptr2int(arg);
	DBPROCESS *dbproc;
	LOGINREC *login;

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

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

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

	pthread_mutex_lock(&mutex);
	++thread_count;
	pthread_mutex_unlock(&mutex);

	printf("thread %2d waiting for all threads to start\n", num+1);
	pthread_mutex_lock(&mutex);
	while (thread_count < NUM_THREAD) {
		pthread_mutex_unlock(&mutex);
		sleep(1);
		pthread_mutex_lock(&mutex);
	}
	pthread_mutex_unlock(&mutex);

	for (i = 1; i <= NUM_LOOP; ++i) {
		printf("thread %2d of %2d loop %d\n", num+1, NUM_THREAD, i);
		if (test(dbproc) || result != 0)
			break;
	}

	dbclose(dbproc);
	return NULL;
}
开发者ID:dparnell,项目名称:freetds,代码行数:47,代码来源:thread.c

示例13: DBSETLUSER

void Connector::set_login_struct(string user , string password )
{
	if ( (login_rec = dblogin()) == FAIL){
		conn_status = false;
		s_error_message.append("Failed to initialize the login struct");
		error_code = 2;
	}

	DBSETLUSER(login_rec, user.c_str());
	DBSETLPWD(login_rec, password.c_str());
	DBSETLAPP(login_rec, "msfmobile");

	char hostname[MAXHOSTNAMELEN];
	int max_len = MAXHOSTNAMELEN;

	if (gethostname(hostname, max_len) == 0){
		DBSETLHOST(login_rec, hostname);
	}
}
开发者ID:20083017,项目名称:mysql_connector,代码行数:19,代码来源:Connector.cpp

示例14: close

bool QTDSDriver::open(const QString & db,
                       const QString & user,
                       const QString & password,
                       const QString & host,
                       int /*port*/,
                       const QString& /*connOpts*/)
{
    if (isOpen())
        close();
    if (!dbinit()) {
        setOpenError(true);
        return false;
    }
    d->login = dblogin();
    if (!d->login) {
        setOpenError(true);
        return false;
    }
    DBSETLPWD(d->login, const_cast<char*>(password.toLocal8Bit().constData()));
    DBSETLUSER(d->login, const_cast<char*>(user.toLocal8Bit().constData()));

    // Now, try to open and use the database. If this fails, return false.
    DBPROCESS* dbproc;

    dbproc = dbopen(d->login, const_cast<char*>(host.toLatin1().constData()));
    if (!dbproc) {
        setLastError(qMakeError(tr("Unable to open connection"), QSqlError::ConnectionError, -1));
        setOpenError(true);
        return false;
    }
    if (dbuse(dbproc, const_cast<char*>(db.toLatin1().constData())) == FAIL) {
        setLastError(qMakeError(tr("Unable to use database"), QSqlError::ConnectionError, -1));
        setOpenError(true);
        return false;
    }
    dbclose( dbproc );

    setOpen(true);
    setOpenError(false);
    d->hostName = host;
    d->db = db;
    return true;
}
开发者ID:Suneal,项目名称:qt,代码行数:43,代码来源:qsql_tds.cpp

示例15: 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


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