Server IP : 103.119.228.120 / Your IP : 18.118.32.7 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/unixODBC-2.3.1/doc/ProgrammerManual/Tutorial/ |
Upload File : |
<HTML> <HEAD> <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1"> <TITLE>Obtainign Datasources</TITLE> <LINK REL="Stylesheet" href="odbc.css"> </HEAD> <BODY bgcolor="white"> <table width="90%" cols="3" border="0"> <TR> <TD colspan="3" class="big">Obtaining a Datasourcename</TD> </TR> <TR> <TD colspan="3"><P>A simple query should be a nobrainer right now. But what if your programm runs on a system where you can't be sure which datasource names are configured?</P> <P>Then you should use <A hrEF="gloss.html#dsn"><CODE>SQLDataSources()</CODE></a>. After allocating a environment handle you may use this to find out about the DSN and the supplied description for the datasource.</P> <P>As ODBC knows systemwide and userwide datasources, you need to give a direction which datasource types you are looking for. There you may specify either of the following values:</P> <TABLE COLS="2" border="0" width="90%"> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of all available datasources (either user or systemwide). </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST_USER</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of the available user datasources. </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_FIRST_SYSTEM</CODE></TD> <TD>Sets up <CODE>SQLDataSources()</CODE> to lookup the first of the available system datasources. </TR> <TR> <TD valign="top"><CODE>SQL_FETCH_NEXT</CODE></TD> <TD>Fetches the next datasource. Depending on <CODE>SQL_FETCH_FIRST_USER</CODE>, <CODE>SQL_FETCH_FIRST_SYSTEM</CODE> or <CODE>SQL_FETCH_FIRST</CODE> this may only be a user datasource, only a system datasource or one of either. </TR> </TABLE> <P>So let's have a look on a small function, which will return all available datasource names. You may insert this code into the program which you built before and call it somewhere after you've obtained an environment handle.</P> <CODE class="list"><PRE> void OD_ListDSN(void) { char l_dsn[100],l_desc[100]; short int l_len1,l_len2,l_next; l_next=SQL_FETCH_FIRST; while( SQLDataSources(V_OD_Env,l_next,l_dsn, sizeof(l_dsn), &l_len1, l_desc, sizeof(l_desc), &l_len2) == SQL_SUCCESS) { printf("Server=(%s) Beschreibung=(%s)\n",l_dsn,l_desc); l_next=SQL_FETCH_NEXT; } } </PRE></CODE> </TD> </TR> </TABLE> </BODY> </HTML>