jianleon 发表于 2006-12-22 12:19:41

用dblibrary读取sybase数据库只能获取最多255个字节的数据吗

<p><span style="FONT-SIZE: 13px;">在linux AS3下装了个12.5的sybase(page size是8),c程序通过dblibrary库实现数据库的读写,但发现通过程序读取的数据最多只有255个字节(实际存储的远不止255),查看了资料没找出原因,望各位帮帮忙。<br/>测试代码如下:</span></p><span style="FONT-SIZE: 13px;"><div class="altbg2" id="code0" style="CLEAR: both; BORDER-RIGHT: #698cc3 1px solid; PADDING-RIGHT: 10px; BORDER-TOP: #698cc3 1px solid; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; MARGIN: 3px 2em 2em; BORDER-LEFT: #698cc3 1px solid; WORD-BREAK: break-all; PADDING-TOP: 5px; BORDER-BOTTOM: #698cc3 1px solid; FONT-FAMILY: fixedsys;">#include &lt;stdio.h&gt;<br/>#include &lt;sybfront.h&gt;<br/>#include &lt;sybdb.h&gt;<br/><br/>int main(argc, argv)<br/>int&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; argc;<br/>char&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;*argv[];<br/>{<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DBPROCESS&nbsp; &nbsp;&nbsp;&nbsp;*dbproc;&nbsp; &nbsp;&nbsp; &nbsp; /* Our connection with SQL Server. */<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LOGINREC&nbsp; &nbsp;&nbsp; &nbsp;*login;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/* Our login information. */<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/* These are the variables used to store the returning data. */<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;RETCODE&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;result_code;<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DBCHAR&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; name1;<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DBCHAR&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; des;<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/* Initialize DB-Library. */<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if (dbinit() == FAIL)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; exit(ERREXIT);<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;login = dblogin();<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DBSETLUSER(login, "sa");<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;DBSETLPWD(login, "intelligence");<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if ((dbproc = dbopen(login, "CHECKSERVER")) == NULL)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; printf("Could not connect to server!\n");<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; return(-1);<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/* First, put the commands into the command buffer. */<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;dbcmd(dbproc, "select name, des from checkdb..test_tb");<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;dbcmd(dbproc, " where name = 'lijm' ");<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;/* Send the commands to SQL Server and start execution. */<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;dbsqlexec(dbproc);<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;while ((result_code = dbresults(dbproc)) != NO_MORE_RESULTS)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; if (result_code == SUCCEED)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; {<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;/* Bind program variables. */<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;dbbind(dbproc, 1, NTBSTRINGBIND, (DBINT)0, <br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;(BYTE DBFAR *)name1);<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;dbbind(dbproc, 2, NTBSTRINGBIND, (DBINT)0, <br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;(BYTE DBFAR *)des);<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;/* Now print the rows. */<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;while (dbnextrow(dbproc) != NO_MORE_ROWS)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;if ((DBCURCMD(dbproc) == 2)<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &amp;&amp; (DBCURROW(dbproc) &gt; 10))<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; continue;<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;printf("name: %s, description: %s",name1,des);<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br/><br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;dbexit();<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;exit(STDEXIT);<br/>}</div></span>

jianleon 发表于 2006-12-22 12:19:59

<font size="2">另外昨天在看《Open Client DB-Library C Reference Manual》时看到这句话:<br/>“DB-Library provides source code compatibility for older Sybase<br/>applications. Sybase encourages programmers to implement<br/>applications with Client-Library or Embedded SQL.”<br/>明显DB-Library是for旧版的Sybase,有没有可能DB-Library本身就只能支持select出最多255个字节的数据,而Client-Library就能支持更大的数据。</font>
页: [1]
查看完整版本: 用dblibrary读取sybase数据库只能获取最多255个字节的数据吗

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com